TEHRAN (AFP) -- Iran said Saturday it "unintentionally" shot down a Ukrainian passenger jet, killing all 176 people aboard, in an abrupt about-turn after initially denying Western claims it was struck by a missile.
President Hassan Rouhani said a military probe into the tragedy had found "missiles fired due to human error" brought down the Boeing 737, calling it an "unforgivable mistake".
At a student protest to pay tribute to the crash victims on Saturday, Iranian authorities briefly detained Britain's ambassador to Tehran, in what the British government called a violation of international law. He was later released.
US President Donald Trump told Iranians that he stands by them and is monitoring the demonstrations.
"To the brave, long-suffering people of Iran: I've stood with you since the beginning of my Presidency, and my Administration will continue to stand with you," he tweeted.
"There can not be another massacre of peaceful protesters, nor an internet shutdown. The world is watching," he added, apparently referring to an Iranian crackdown on street protests that broke out in November.
Earlier, Canadian Prime Minister Justin Trudeau demanded that Iran provide "full clarity" on the downing of the plane, which Ottawa says had 57 Canadian citizens aboard.
"A full and complete investigation must be conducted," Trudeau said. "Iran must take full responsibility."
Iran's Supreme Leader Ayatollah Ali Khamenei also offered his condolences and ordered the armed forces to address "shortcomings" so that such a disaster does not happen again.
Tehran's acknowledgement came after officials in Iran denied for days Western claims that the Ukraine International Airlines plane had been struck by a missile in a catastrophic error.
The Kiev-bound jet slammed into a field shortly after taking off from Tehran's Imam Khomeini International Airport on Wednesday.
The crash came hours after Tehran launched missiles at bases hosting American forces in Iraq in response to the killing of top Iranian general Qasem Soleimani in a US drone strike.
Fears grew of an all-out war between Iran and its arch-enemy the United States, but those concerns have subsided after Trump said Tehran appeared to be standing down after targeting the US bases.
On Saturday evening, police dispersed students who had converged on Amir Kabir University in Tehran to pay tribute to the victims, after some among the hundreds gathered shouted "destructive" slogans, Fars news agency said.
British Foreign Secretary Dominic Raab said UK envoy Rob Macaire had been detained.
"The arrest of our ambassador in Tehran without grounds or explanation is a flagrant violation of international law," Raab said in a statement. The US called on Iran to apologise.
Iran's Tasnim News Agency, which is close to the country's conservatives, said the envoy had been "provoking radical acts" among students. He was released a few hours later and would be summoned again by Iranian officials on Sunday, it said.
State television reported that students shouted "anti-regime" chants, while Fars reported that posters of Soleimani had been torn down.
The aerospace commander of Iran's Revolutionary Guards accepted full responsibility for Wednesday's accident.
But Brigadier General Amirali Hajizadeh said the missile operator acted independently, targeting the 737 after mistaking it for a "cruise missile".
The operator failed to obtain approval from his superiors because of disruptions to a communications system, he said.
"He had 10 seconds to decide. He could have decided to strike or not to strike and under such circumstances, he took the wrong decision."
Iran had been under mounting international pressure to allow a "credible" investigation after video emerged appearing to show the moment the airliner was hit.
In footage that the New York Times said it had verified, a fast-moving object is seen rising into the sky before a bright flash appears. Several seconds later, an explosion is heard.
Iran's military said it had been at the highest level of alert after American "threats" and that the plane had turned and come close to a "sensitive" military site before it was targeted due to "human error".
Rouhani said Iran had been on alert for possible US attacks after Soleimani's "martyrdom".
The European Union's air safety agency on Saturday advised airlines to avoid flying over Iran.
"Iran is very much saddened by this catastrophic mistake and I, on behalf of the Islamic Republic of Iran, express my deep condolences to the families of victims of this painful catastrophe," the president said.
Rouhani added he had ordered "all relevant bodies to take all necessary actions (to ensure) compensation" to the families of those killed
The majority of passengers on Flight PS752 were Iranians and Canadians, including dual nationals, while Ukrainians, Afghans, Britons and Swedes were also aboard.
Rouhani told his Ukrainian counterpart Saturday that "all the persons involved in this air disaster will be brought to justice," Ukraine's presidency said.
President Volodymyr Zelensky said earlier on Facebook "we expect Iran... to bring the guilty to the courts."
This is Iran's worst civil aviation disaster since 1988 when the US military said it shot down an Iran Air plane over the Gulf by mistake, killing all 290 people on board. (AFP)