Hamas won the Palestinian legislative elections in 2006, giving it a legitimate claim to form the government. A power struggle with the Fatah movement, which controlled the presidency and much of the security apparatus, led to a national unity government that quickly dissolved into violence.