The Basque separatist group ETA was believed behind the assassination, which brought an early halt to campaigning for Sunday's parliamentary elections and left politicians from both main parties scrambling to show solidarity.
After the bombings in 2004, voters threw out a conservative government. It's unclear whether Prime Minister Jose Luis Rodriguez Zapatero will be punished this time. At the least, the death of former city councilman Isaias Carrasco is a setback for the socialist leader, who has vainly tried to reach peace with ETA.
The killing occurred about 1:30 p.m. in the Basque town of Arrasate, as Carrasco left the home he shared with his wife and children. Witnesses said a gunman wearing a false beard fired five shots, then sped away in a gray car as Carrasco's wife and daughter screamed.
Authorities said the 42-year-old socialist politician was hit at least three times, including in the head and chest.
There was no claim of responsibility, but the government was quick to blame ETA, which set off a series of small bombs ahead of the vote and killed two Spanish policemen just across the border in France on Dec. 1.
A grim-faced Zapatero cut short a campaign swing through the southern city of Malaga and rushed back to the capital, vowing to use every means at his disposal to hunt down the killers.
"We knew that ETA could still cause irreparable damage and pain to Spaniards," he said in a televised address. "Today they have added another victim to their long and ignominious list."
Zapatero's main rival, Mariano Rajoy of the conservative Popular Party, issued a call for unity, saying politics must be put aside in the fight against terrorism. But he also took a swipe at the government's effort to negotiate with ETA, saying the only way to deal with the group is through force.
Before the killing, three opinion polls gave Zapatero a slight lead. With campaigning over and a ban on further surveys before the ballot, it will be impossible to determine the effect of the violence on voters until they go to the polls Sunday.
Ramon Cotarelo, a professor of political science at Madrid's Complutense University, said the fact that the victim was from Zapatero's socialist party might spark sympathy for the prime minister.
"But it could go the other way," he added. "People might say: 'Iron fist. The Socialists are no good. Look, they negotiate and it does no good. You have to vote for the right.'"
Others were not so sure the killing would have any effect.
"I can't imagine what mental process might exist to make a person change their vote because of this," said Carlos Taibo, a professor at Madrid's Autonomous University. "I don't believe that this would make people say, 'We're not going to support the socialist Party or we're going to stop supporting the Popular Party."
Before the killing, the election campaign had been marked by nastiness, with Rajoy repeatedly calling Zapatero a liar about his dealings with ETA and other issues.
The conservative has tried to depict the prime minister as naive for trusting the Basque separatists and dishonest for continuing to hold secret indirect talks with them even after a bombing at Madrid's airport killed two people on Dec. 30, 2006.
Zapatero, who was going to Arrasate to see the victim's family, counters that the opposition has broken a taboo of Spanish politics by politicizing terrorism.
Extricating the issue of terrorism from politics has been nearly impossible in Spain in recent years.
The last national election in 2004 was held three days after the March 11 terror attack by Islamic militants on four Madrid commuter trains that killed 191 people and wounded some 1,800.
The conservative government in power then blamed ETA even as evidence mounted that extremist Muslims were involved. Many voters felt the government was trying to dispel perceptions that its support for the Iraq war had made Spain a target for al-Qaida, and the conservatives lost the election.
Cotarelo, the political science professor, said that even though the scale of bloodshed is different this time, the attack is a clear bid by ETA to insert itself into the political process.
"ETA is sending a message that this is like the March 11 attacks: `We are like the Muslims. We influence elections that are 24 hours away'," he said.
Interior Minister Alfredo Perez Rubalcaba said last month that he expected ETA to try to stage a deadly attack before the election, and the country has been on maximum terrorism alert for two weeks. ETA usually claims responsibility for its attacks, but often weeks later.
ETA declared what it called a permanent cease-fire in March 2006 and said it wanted a negotiated settlement to a conflict in which it has killed more than 800 people.
But the group — classified as a terrorist organization by Spain, the European Union and the United States — grew frustrated with a lack of concessions in ensuing peace talks with Zapatero's government.
ETA detonated a car bomb at a parking garage at Madrid's Barajas airport at the end of 2006, killing two people. But the group insisted the deaths were unintended and said the cease-fire still held.
It formally called off the truce last June, and has since staged more than a dozen mostly minor bombings.
Associated Press writers Daniel Woolls, Ciaran Giles and Harold Heckle contributed to this report.