This gets a little messy.
Hamas and Fatah (the party of the Palestinian Authority) have been at one another's throats for decades. To oversimplify, the PLO (the organization of parties that Yasser Arafat headed as the chairman of Fatah) wasn't militant enough for Hamas. Think of the divide as the schism between the classic IRA and the provisionals. To Hamas, Arafat was a sellout. They'll accept nothing less than the whole West Bank, reparations and other demands.
It once was the case that the Palestinian territories held elections, except there was this problem in early 2006, which was that Hamas won the legislative election. Hamas refuses to recognize Israel, so international aid from the US, EU, UN and Russia was suspended. With Fatah's Mahmoud Abbas as president, they also got even less done legislatively than a divided government in the United States.
After about a year and a half of ugly back-and-forth without results, Hamas finally had enough. They more or less invaded Gaza, seized control and deported the members of Fatah in the government. The PA reciprocated in the West Bank, so when Israel says they're declaring war on Hamas, what they mean is that they're declaring war on Gaza.
There haven't been elections in the West Bank since. Mahmoud Abbas is functionally a dictator, but he's the guy the West and Russia are willing to work with, so they all recognize him as the legitimate leader. This is far from the only place in the world where the western democracies have entertained that little hypocrisy in the furtherance of policy ends.