TEHRAN, IRAN -- Iran announced Saturday that its military "unintentionally" shot down the Ukrainian jetliner that crashed earlier this week, killing all 176 aboard, after the government had repeatedly denied Western accusations that it was responsible.

The plane was shot down early Wednesday, hours after Iran launched a ballistic missile attack on two military bases housing U.S. troops in Iraq in retaliation for the killing of Iranian Gen. Qassem Soleimani in an American airstrike in Baghdad. No one was wounded in the attack on the bases.

A military statement carried by state media said the plane was mistaken for a "hostile target" after it turned toward a "sensitive military centre" of the Revolutionary Guard. The military was at its "highest level of readiness," it said, amid the heightened tensions with the United States.

"In such a condition, because of human error and in a unintentional way, the flight was hit," the military said. It apologized and said it would upgrade its systems to prevent future tragedies.

It also said those responsible for the strike on the plane would be prosecuted.

Iran's acknowledgement of responsibility for the crash was likely to inflame public sentiment against authorities after Iranians had rallied around their leaders in the wake of Soleimani's killing. The general was seen as a national icon, and hundreds of thousands of Iranians had turned out for funeral processions across the country.

But the majority of the plane crash victims were Iranians or Iranian-Canadians, and the crash came just weeks after authorities quashed nationwide protests ignited by a hike in gasoline prices.

Iran's President Hassan Rouhani blamed the tragedy on "threats and bullying" by the United States after the killing of Soleimani. He expressed condolences to families of the victims, and he called for a "full investigation" and the prosecution of those responsible.

"A sad day," Iran's Foreign Minister Mohammad Javad Zarif tweeted. "Human error at time of crisis caused by US adventurism led to disaster. Our profound regrets, apologies and condolences to our people, to the families of all victims, and to other affected nations."

Prime Minister Justin Trudeau released a statement in the early hours of Saturday, saying "our focus reimains closure, accountability, transparency and justice for the families and loved ones of the victims.

"This is a national tragedy, and all Canadians and mourning together."

Trudeau added that the Canadian government expects "full co-operation from Iranian authorities."

The jetliner, a Boeing 737 operated by Ukrainian International Airlines, went down on the outskirts of Tehran shortly after taking off from Imam Khomeini International Airport.

Iran had denied for several days that a missile caused the crash. But then the U.S. and Canada, citing intelligence, said they believed Iran shot down the aircraft with a surface-to-air missile, a conclusion supported by videos of the incident.

The plane, en route to the Ukrainian capital of Kyiv, was carrying 167 passengers and nine crew members from several countries, including 82 Iranians, 57 Canadians and 11 Ukrainians, according to officials. The Canadian government had earlier lowered the nation's death toll from 63.

"This is the right step for the Iranian government to admit responsibility, and it gives people a step toward closure with this admission," said Payman Parseyan, a prominent Iranian-Canadian in western Canada who lost a number of friends in the crash.

"I think the investigation would have disclosed it whether they admitted it or not. This will give them an opportunity to save face."

With files from CTVNews.ca

Armed Forces’ internal investigation has concluded that regrettably missiles fired due to human error caused the horrific crash of the Ukrainian plane & death of 176 innocent people.

Investigations continue to identify & prosecute this great tragedy & unforgivable mistake. #PS752 — Hassan Rouhani (@HassanRouhani) January 11, 2020

A sad day. Preliminary conclusions of internal investigation by Armed Forces:



Human error at time of crisis caused by US adventurism led to disaster



Our profound regrets, apologies and condolences to our people, to the families of all victims, and to other affected nations.

— Javad Zarif (@JZarif) January 11, 2020

------

Associated Press writers Jon Gambrell and Joseph Krauss in Dubai, United Arab Emirates, and Rob Gillies in Toronto, contributed to this report.