The Spanish defence ministry says 17 of its Nato peacekeepers have been killed in a helicopter crash in Afghanistan.
Five other Spanish troops were hurt when a second Puma helicopter made an emergency landing, it said.
Some reports blamed mechanical failure but Madrid said it could not rule out that the incident near Herat, western Afghanistan, was caused by enemy fire.
The helicopters were on a training exercise ahead of parliamentary elections, officials said.
Afghan President Hamid Karzai said he was deeply saddened by the crash and said Afghanistan would "remember the services of these brave soldiers who have made sacrifices so that the people of Afghanistan could live in peace".
The cause of the crash is still in doubt. Some reports suggest that a sandstorm hit the area shortly before the incident.
And a spokesman for the Nato-led International Security Assistance Force (Isaf), Maj Andrew Elmes, said the incident was more likely a case of "mechanical failure".
A top Taleban commander, Mullah Dadullah, told Reuters their fighters had shot down the helicopter but his claims could not be verified.
Spanish Defence Minister Jose Bono said: "It may have been an accident or it may have been an attack from the outside.
"It has absolutely not been ruled out that it might have been an attack," he said.
Although the region was mountainous, the helicopter came down on level ground, Mr Bono said.
Nato forces in the area launched a rescue mission and a number of injured soldiers have been taken to hospital.
Spain has about 850 troops deployed in the country
Spanish Prime Minister Jose Luis Rodriguez Zapatero has cut short his holiday in the Canary Islands to return to Madrid.
The crash is the second air disaster for Spanish troops in Afghanistan. Sixty-two peacekeepers died in a plane crash in Turkey in 2003 when returning from Afghanistan.
Spain has about 850 troops deployed in the country.
In June a US military Chinook helicopter came down in eastern Afghanistan, killing all 16 on board.
The Taleban claimed to have shot down the helicopter and the US conceded that "hostile fire" may have been to blame for the incident.
The area around Herat is generally considered more stable than areas of southern and eastern Afghanistan where the Taleban are more active.
There are currently more than 8,000 troops serving with Isaf, which is largely concentrated around Kabul.
Nato has recently announced its commitment to expand peacekeeping operations to cover the whole of Afghanistan by 2006.