Spain's Socialist Party prime minister-elect says he will pull troops out of Iraq - unless the UN takes charge.
Spain has more than 1,300 troops in Iraq
Jose Luis Rodriguez Zapatero said: "The war in Iraq was a disaster, the
occupation of Iraq is a disaster."
He called for a grand international alliance against terror and an end to "unilateral wars".
The Socialists won a shock poll victory after voters appeared to turn on the government over its handling of the Madrid bombings that killed 200 people.
Police are quizzing five men over the bombings, amid reports that one of them has links to a group blamed for attacks in Casablanca last May that killed 45 people.
Spain supported the US-led war on Iraq despite much domestic opposition. It currently has 1,300 troops in the Polish-led multinational force in the central-south sector.
Meanwhile, Poland - another key US ally - pledged to keep its 2,400 troops in Iraq. However, Polish Prime Minister Leszek Miller admitted the defeat of the Spanish conservatives could cause "very serious complications" for Warsaw.
"Revising our positions on Iraq after terrorist attacks would be to admit that terrorists are stronger and that they are right," Mr Miller told reporters in Tarnow.
Warsaw's ambassador to Nato, Jerzy Nowak, told Reuters news agency Poland was prepared to stay in charge of the 9,000-strong if Spain, which had been due to take over on 1 July, withdrew.
At a news conference in Madrid, Mr Zapatero said his priority will be a "systematic fight against terrorism of all kinds".
He again reiterated his opposition to the US-led war in Iraq, but said his government would maintain what he described as "cordial relations" with Washington.
However Mr Zapatero said President Bush and UK Prime Minister Tony Blair needed to "engage in some self-criticism" over their decision to invade Iraq.
A brief telephone conversation between Mr Zapatero and Mr Bush on Monday is reported to have been cordial.
A White House spokesman said Mr Bush congratulated the Spanish leader on his election victory and gave his condolences for Thursday's attacks.
SPANISH ELECTION RESULT
IU - United Left (pro-communist)
PSOE - Socialist Party
PP - Popular Party
CiU - Convergence and Union (moderate Catalan nationalists)
ERC - Republican Left of Catalonia
PNV - Basque Nationalist Party
Mr Zapatero said Spanish soldiers would be pulled out if there was no change in Iraq by the 30 June deadline for transfer of sovereignty.
BBC News Online's world affairs correspondent, Paul Reynolds, says that the situation in Iraq may well have changed by 30 June, but whether that influences the new government remains to be seen.
By then the US and UK hope that the Security Council will have given UN approval to the handover plan.
In addition the interim Iraqi government will be asking foreign troops to stay as part of a UN-approved multinational force.
Socialists won 42% of the vote, while the centre-right Popular Party won 38% in Sunday's general election, held in the wake of the Madrid train bomb attacks that killed 200 people.
The BBC's Chris Morris, in Madrid, says the bombings did more than shock Spain to the core; they proved to be the decisive factor in the general election that ousted the government.
Mr Zapatero was - until Thursday's bombings - considered an outsider for Spain's top job.
Despite his party's victory, however, there is expected to be much political horse-trading because the Socialists did not win an absolute majority.
While Mr Zapatero said his first priority was to tackle terrorism "in all its forms", he is thought likely to do it in a very different way than the outgoing government.
A larger than expected 77% of the electorate turned out to vote in the wake of last Thursday's attacks.
Our correspondent says the late swing to the Socialists raises one disturbing thought - if al-Qaeda was responsible for Thursday's attacks, it appears to have had significant influence in changing the government of a leading Western democracy.
Investigations are continuing into who was behind the bombings.
A videotaped claim of responsibility by a man identifying himself as al-Qaeda's military spokesman in Europe forced the government to change its stance on the most likely suspects.
The tape - claiming revenge for Spain's "collaboration with the criminals Bush and his allies" - was found in a litter bin on Saturday following a tip-off to a TV station.
'Suspect has al-Qaeda link'
Three Moroccans and two Indians are being held in connection with the attacks.
The three Moroccans being held have been named as Jamal Zougam, 30, Mohamed Bekkali, 31, and Mohamed Chaoui, 34.
The two Indians arrested were named as Vinay Kohly and Suresh Kumar.
Spain's El Pais newspaper reported that investigators had found links between Jamal Zougam and the Salafia Jihadia group held responsible for attacks in Casablanca last May in which more than 40 people died.
One of the targets of the Moroccan attacks was a Spanish cultural centre, where four Spaniards were among the dead.
Reports also linked Jamal Zougam to a Spanish cell of al-Qaeda which was headed by Imad Eddin Barakat Yarkas, also known as "Abu Dahdah".
Abu Dahdah has been indicted by the Spanish anti-terrorist prosecutor Baltasar Garzon on charges relating to the preparation of the attacks of September 11, 2001 in the United States.
El Pais said Jamal Zougam was cited at two points in judge Garzon's indictment, but was not charged.