al-Qaeda bombing of Spain, the day before the election in 2004 changed the winner.
The public seemed convinced that the Madrid Bombings were a result of the Aznar government’s alignment with the U.S. and its invasion of Iraq. The terrorists behind the 11-M attack were somewhat successful because of the election outcome. Before the attack, the incumbent Popular Party led the polls by 5 percent. It is believed that the Popular Party would have won the election if it had not been for the terrorist attack. The Socialist Party, led by José Luis Rodríguez Zapatero, ended up winning the election by 5%. The Socialist Party had called for the removal of Spanish troops from Iraq during its campaigning. Zapatero promised to remove Spanish troops by 30 June 2004, and the troops were withdrawn a month earlier than expected. Twenty-eight percent of voters said that the bombings influenced their opinions and vote. A massive amount of 1 million voters switched their vote to the Socialist Party after the Madrid bombings. These voters who switched their vote were no longer willing to support the Popular Party’s stance on war policy. The bombings also influenced 1,700,000 citizens to vote who did not plan on originally voting. On the other hand, the terrorist attacks discouraged 300,000 people from voting. Overall, there was a net 4 percent increase in voter turnout.[86]
https://en.wikipedia.org/wiki/2004_M...train_bombings