Updated

Jose Luis Rodriguez Zapatero, Spain's young and largely untested Socialist leader, won parliamentary approval Friday as prime minister, stepping forward to govern a nation shocked by a terrorist bombing and Al Qaeda threats of more bloodshed.

A total of 183 lawmakers in the 350-seat Congress of Deputies (search) voted for Zapatero, who led his party to a surprise victory in Spain's March 14 general election and has pledged to withdraw Spanish troops from Iraq by June 30 unless the United Nations takes over political and military control in that country.

Zapatero's Spanish Socialist Workers Party (search) won 164 seats in the election, 12 short of a majority.

The 148 lawmakers from the outgoing conservative Popular Party voted against his nomination Friady, but Basque (search) and Catalan (search) regional nationalist parties, holding 19 votes, abstained.

Despite receiving help in the vote, Zapatero, 43, will lead a minority Socialist government, not a coalition.

Closing more than a day of debate before the vote, Zapatero told lawmakers: "Let's get to work."

After the speaker of Parliament, Manuel Marin, announced the results, Zapatero sat smiling as he received a standing ovation from many lawmakers.

The first to walk across the chamber and congratulate him was the outgoing premier, Jose Maria Aznar.

Parliament's decision returns the Socialists to power after eight years in the opposition under Aznar, who angered millions of Spaniards by backing the U.S.-led war in Iraq and was accused of provoking the March 11 terror attacks in Madrid with that support.

Aznar's Popular Party had been expected to win the election handily. But the voting was thrown wide open by the terror bombings and a reported Al Qaeda claim on the eve of the election that the attacks were punishment for his support of the war.

Aznar himself was not seeking a third term.

In the wee hours of Friday, after a day of debate on swearing him in, Zapatero vowed to honor his pledge on the 1,300 Spanish troops in Iraq.

"If the United Nations does not take over political control and the military command in that country, the Spanish troops will come back to be with us. And I have set a deadline of June 30," Zapatero said. June 30 is when the troops' mandate expires. The date was set by the outgoing conservative government.

Zapatero is a former law professor who has held a seat in Parliament since 1986 but never served as a minister or any other senior government position. He has been his party's leader since 2000.

Iraq is not the only red-hot policy issue he faces.

Spain is still recovering from the March 11 commuter rail terror bombings, which killed 191 people, and faces threats of more attacks from an Al Qaeda-linked group demanding that Spain withdraw its troops from Iraq and Afghanistan.

Troops are patrolling rail lines, nuclear power plants and other potential targets. Day after day, newspapers run stories about families shattered by the loss of loved ones in the terror attack.

In Thursday's debate, Zapatero vowed a tough line against terror.

"The main objective of the government I preside over will be to wage an all-out war on terrorism, against any terrorism, against all terrorism," he said.

The 1,300 Spanish troops in Iraq, stationed in Diwaniya and the Shiite holy city of Najaf, come under rifle and mortar fire almost every day from militiamen loyal to the fiery anti-U.S. cleric Muqtada al-Sadr.

A poll by the radio station Cadena Ser released March 29 showed 72 percent of Spaniards support Zapatero's plans on Iraq. A rally was planned for Friday evening outside Parliament to urge Zapatero to keep his word.

At home Zapatero also faces pressure from restive semiautonomous regions like the Basque country and Catalonia, which are seeking more self-rule, challenging the central government in Madrid.

In domestic policy debate Thursday, Zapatero pledged greater spending on education, research and development, affordable housing for low- and middle-income families, a crackdown on violence against women — a scourge he called Spain's "greatest national disgrace" — and recognition of homosexual marriage.