A Ukrainian plane that crashed earlier this week in Iran was shot down unintentionally due to human error, the Iranian military has said in a statement read on state TV.

The statement stated that the plane had flown close to a sensitive military site belonging to the elite Revolutionary Guards.

The responsible parties would be referred to a judicial department within the military and held accountable, the statement said.

The military said the plane had been mistaken for a hostile jet.

All 176 people on board were killed in the crash.

The Iranian military statement expressed condolences to the families of the victims.

The United States and Canada had said that the plane was shot down, a claim Iran had initially denied.

The Iranian president, Hassan Rouhani, has described the incident as a "great tragedy and unforgivable mistake".

The country's foreign minister Javid Zarif said it was "human error at a time of crisis caused by US adventurism".

The foreign minister continued to tweet about the incident later in the day, saying he and his colleagues are ready to assist the families of the victims.

Wednesday's crash heightened pressure on Iran after months of friction with the US and tit-for-tat attacks.

A US drone strike had killed an Iranian general in Iraq on 3 January, prompting Tehran to fire at US targets on Wednesday.

Canada, which had 57 citizens on board, and the United States both said they believed an Iranian missile brought down the aircraft although they said it was probably an accident.

Canada's foreign minister had told Iran "the world is watching."

The Prince of Wales offered a message to Canada's Governor-General which said: "My wife and I were utterly horrified by the appalling disaster in Iran in which so many Canadian citizens lost their lives so tragically. We can only begin to imagine the heart-rending anguish of the families and friends of those who were killed in this catastrophe."

He continued; "however hopelessly inadequate it may be, we particularly wanted you to know just how much our hearts go out to all those whose grief must be unbearable." 

Responding to Iran's U-turn, Ukraine's President Volodymyr Zelenskiy said he wanted an official apology and full co-operation, demanding those responsible to be held to account.

Experts said mounting international scrutiny would have made it all but impossible to hide signs of a missile strike in an investigation and Iran may have felt a swift policy reversal was better than battling rising criticism abroad, as well as facing growing anger and grief over the crash at home.

Many victims were Iranians with dual nationality.

An Iranian military statement, the first to indicate Iran's shift in position, said the plane had flown close to a sensitive military site belonging to the elite Revolutionary Guards.

It said that, at the time, planes had been spotted on radar near strategic sites which led to "further alertness" in air defence units, adding that responsible parties would be referred to a judicial department in the military.

Ukraine's Foreign Minister Vadym Prystaiko had said yesterday that the plane was following a normal flight corridor.

Experts said an inquiry would almost certainly have shown up tell-tale holes and other signs on the remains of the fuselage that a missile was to blame for the incident.

Mobile phone footage posted and circulated by ordinary Iranians on Twitter after the crash had indicated that it came down in a ball of flames and exploded as it struck the ground.

Iran had said on Thursday it would download the information from voice and flight data recorders to determine what had happened, although it had said the process could take one to two months.

Tehran had said it could ask Russia, Canada, France or Ukraine for help, saying an investigation could take one or two years.

In its initial denials, Iran had said accusations that a missile was to blame were "psychological warfare".

Grief-stricken Iranians and others posted images related to the crash. Many complained Iran's authorities had spent too much time trying to fend off criticism over the disaster instead of offering condolences and sympathising with victims.

One image circulating on social media showed a child's red shoe in the dirt. Another was a selfie of a mother and daughter in their seats, sent to a loved one just before takeoff.

Ukraine had been looking at various possible causes of the crash, including an attack by a Russian-made missile, a collision, an engine explosion or terrorism.

A US official had said data showed the plane airborne for two minutes after departing Tehran when heat signatures of two surface-to-air missiles were detected.

There was an explosion in the vicinity and heat data showed the plane on fire as it fell.

US military satellites detect infrared emissions from heat.

US President Donald Trump had said "somebody could have made a mistake."

The disaster had echoes of an incident in 1988, when the US warship USS Vincennes shot down an Iranian airliner, killing 290 people.

Washington said it was a tragic accident.

Tehran said it was intentional.