Australian Foreign Minister Alexander Downer had criticised Spain on Sunday for pulling its troops from Iraq, saying it encouraged "terrorists" to continue their agenda.
His comments came soon after a group claiming to be the European wing of al-Qaida threatened attacks on Australia and Italy if they did not withdraw their soldiers from Iraq.
Spain's under-secretary for foreign affairs, Luis Calvo Merino, delivered the "firm rejection of the Spanish government" to ambassador Susan Tanner on Monday.
The Spanish government issued a statement saying Madrid "has established the struggle against terrorism as a clear foreign policy priority."
It added Downer's comments were therefore unacceptable, "all the more so as they come from a friendly country such as Australia."
Spain's Socialist government, which took power in April, quickly made good on a campaign pledge to withdraw Spanish soldiers from Iraq. The last troops of a contingent that once numbered 1400 left on 21 May.
The Socialists, however, had pledged to pull out of Iraq if they won the elections well before the 11 March train bombs, which investigators blame on individuals acting in the name of al-Qaida.
The blasts occured three days before a general election, which the Socialists unexpectedly won.
Spanish troops completed their
withdrawal much to US protests
The new government says the Iraq pullout was the Spanish electorate's choice and not a result of the attacks.
Some foreign commentators have none the less said the decision, which drew fire from Washington, gave the impression Spain had caved in to terrorists.
The group making the threats against Australia and Italy urged the US allies to "follow the path of the Philippines and Spain", referring also to the Philippines decision to pull out troops from Iraq to save the life of a Filipino captive.
Downer rejected the threats and said Australia would not let terrorists determine its policy, saying the Spanish and Philippines decision had encouraged them to continue with such threats.
"So now we are subjected, as the Italians are, and the Poles and the Bulgarians, to further threats," he said.
In related news, former Spanish Prime Minister Jose-Maria Aznar on Monday firmly denied holding onto intelligence documents relating to the 11 March train bombings.
"I want to state that I am not in material possession of the documents to which you refer in your letter," Aznar said in response to a letter from Alberto Saiz, head of the Spanish intelligence service CNI.
Aznar caused a storm on 16 July when he told a Colombian radio station he had retained some intelligence material regarding 11 March and that this was understandable "as I was prime minister".
Saiz was outraged and demanded Aznar, whose comments on Monday appeared to contradict his earlier assertion, should return them.
"I reiterate for my part that I have strictly complied with all my legal obligations," said Aznar, who has just ended a South American tour to promote his memoirs of eight years in power.
His right-wing Popular Party lost a general election three days after the bombings of four commuter trains, though he was not himself standing for re-election, having handed the party reins over to former deputy Mariano Rajoy.
Did former Spanish PM Aznar
retain intelligence information?
Aznar complained that people were making "arbitrary" assumptions that he was guilty of any wrongdoing.
In a letter back to Saiz Aznar wrote, "as prime minister I received the documentation produced by the centre in line with the fulfilling of functions as laid down by the law".
The issue of just what and when the Aznar government knew about the 11 March attacks, the worst in Spain's history, is highly controversial. While some in his former cabinet blamed Basque separatists for the blasts, others claimed that Moroccans were responsible.