Britain’s ambassador to Tehran has been summoned to explain his “illegal and inappropriate presence” at an anti-government protest, the Iranian foreign ministry has said.

Rob Macaire was called to the Ministry of Foreign Affairs following his arrest on Saturday at a rally where demonstrators condemned the downing of a Ukrainian airliner by Iranian forces.

The ambassador has insisted he had been attending a vigil for the victims of the fatal plane crash when protests broke out, at which point he left.

The summoning threatens to further escalate the diplomatic row between London and Tehran after foreign secretary Dominic Raab denounced Mr Macaire’s detention as a “flagrant violation” of international law.

Boris Johnson and German chancellor Angela Merkel condemned the arrest of Mr Macaire, a spokesman from the prime minister’s office said in a statement issued after the two leaders spoke on Sunday.

Dozens of Iranian hardliners have gathered outside the British embassy, chanting “death to England” while burning a Union Jack and calling for the ambassador to be expelled.

Iran plane crash: Ukraine Boeing 737 comes down near Tehran Show all 18 1 /18 Iran plane crash: Ukraine Boeing 737 comes down near Tehran Iran plane crash: Ukraine Boeing 737 comes down near Tehran People stand near the wreckage after a Ukrainian plane carrying 176 passengers crashed near Imam Khomeini airport in Tehran ISNA/AFP via Getty Iran plane crash: Ukraine Boeing 737 comes down near Tehran People and rescue teams are pictured amid bodies and debris All 176 people on board a Ukrainian passenger plane were killed when it crashed shortly after taking off, Iranian state media reported ISNA/AFP via Getty Iran plane crash: Ukraine Boeing 737 comes down near Tehran One of the engines State news agency IRNA said 167 passengers and nine crew members were on board the aircraft operated by Ukraine International Airlines Iran Press via Reuters Iran plane crash: Ukraine Boeing 737 comes down near Tehran Rescue teams work at the scene AFP via Getty Iran plane crash: Ukraine Boeing 737 comes down near Tehran Passengers' belongings West Asia News Agency via Reuters Iran plane crash: Ukraine Boeing 737 comes down near Tehran Members of the International Red Crescent collect bodies of victims EPA Iran plane crash: Ukraine Boeing 737 comes down near Tehran Rescue teams work amidst debris AFP via Getty Iran plane crash: Ukraine Boeing 737 comes down near Tehran A relative of a victim reacts at Boryspil International Airport, outside Kiev Reuters Iran plane crash: Ukraine Boeing 737 comes down near Tehran Rescue workers search the scene where a Ukrainian plane crashed in Shahedshahr, southwest of the capital Tehran, Iran, Wednesday, Jan. 8, 2020. A Ukrainian airplane with more than 170 people crashed on Wednesday shortly after takeoff from Tehran's main airport, killing all onboard. (AP Photo/Ebrahim Noroozi) Ebrahim Noroozi AP Iran plane crash: Ukraine Boeing 737 comes down near Tehran TOPSHOT - People and rescue teams are pictured amid the wreckage after a Ukrainian plane carrying 176 passengers crashed near Imam Khomeini airport in the Iranian capital Tehran early in the morning on January 8, 2020, killing everyone on board. - The Boeing 737 had left Tehran's international airport bound for Kiev, semi-official news agency ISNA said, adding that 10 ambulances were sent to the crash site. (Photo by Rouhollah VAHDATI / ISNA / AFP) (Photo by ROUHOLLAH VAHDATI/ISNA/AFP via Getty Images) ROUHOLLAH VAHDATI ISNA/AFP via Getty Iran plane crash: Ukraine Boeing 737 comes down near Tehran Rescue workers carry the body of a victim of an Ukrainian plane crash in Shahedshahr, southwest of the capital Tehran, Iran, Wednesday, Jan. 8, 2020. A Ukrainian airplane carrying 176 people crashed on Wednesday shortly after takeoff from Tehran's main airport, killing all onboard. (AP Photo/Ebrahim Noroozi) Ebrahim Noroozi AP Iran plane crash: Ukraine Boeing 737 comes down near Tehran Part of the wreckage Iran Press via Reuters Iran plane crash: Ukraine Boeing 737 comes down near Tehran Debris of a plane belonging to Ukraine International Airlines, that crashed after taking off from Iran's Imam Khomeini airport, is seen on the outskirts of Tehran, Iran January 8, 2020. Nazanin Tabatabaee/WANA (West Asia News Agency) via REUTERS ATTENTION EDITORS - THIS IMAGE HAS BEEN SUPPLIED BY A THIRD PARTY WANA NEWS AGENCY West Asia News Agency via Reuters Iran plane crash: Ukraine Boeing 737 comes down near Tehran Rescue workers search the scene where an Ukrainian plane crashed in Shahedshahr, southwest of the capital Tehran, Iran, Wednesday, Jan. 8, 2020. A Ukrainian airplane carrying 176 people crashed on Wednesday shortly after takeoff from Tehran's main airport, killing all onboard. (AP Photo/Ebrahim Noroozi) Ebrahim Noroozi AP Iran plane crash: Ukraine Boeing 737 comes down near Tehran Rescue team work at the scene where an Ukrainian plane crashed in Shahedshahr, southwest of the capital Tehran, Iran, Wednesday, Jan. 8, 2020. A Ukrainian airplane carrying 176 people crashed on Wednesday shortly after takeoff from Tehran's main airport, killing all onboard. (AP Photo/Ebrahim Noroozi) Ebrahim Noroozi AP Iran plane crash: Ukraine Boeing 737 comes down near Tehran CORRECTS YEAR - Debris is seen from a plane crash on the outskirts of Tehran, Iran, Wednesday, Jan. 8, 2020. A Ukrainian airplane carrying at least 170 people crashed on Wednesday shortly after takeoff from Tehranâ€™s main airport, killing all onboard, state TV reported. (AP Photos/Mohammad Nasiri) Mohammad Nasiri AP Iran plane crash: Ukraine Boeing 737 comes down near Tehran Officials inspect the wreckage EPA Iran plane crash: Ukraine Boeing 737 comes down near Tehran Debris is seen from an Ukrainian plane which crashed as rescue workers search the scene in Shahedshahr, southwest of the capital Tehran, Iran, Wednesday, Jan. 8, 2020. A Ukrainian airplane carrying 176 people crashed on Wednesday shortly after takeoff from Tehran's main airport, killing all onboard. (AP Photo/Ebrahim Noroozi) Ebrahim Noroozi AP

Mr Macaire tweeted on Sunday morning: “Can confirm I wasn’t taking part in any demonstrations! Went to an event advertised as a vigil for victims of #PS752 tragedy.

“Normal to want to pay respects – some of victims were British. I left after 5 mins, when some started chanting.”

He added: “Detained half an hour after leaving the area. Arresting diplomats is of course illegal, in all countries.”

The semi-official Tasnim news agency said he was one of a number of people arrested outside the Amir Kabir University on suspicion of organising, provoking and directing radical actions.

Officials stand near the wreckage of a Ukraine International Airlines Boeing 737-800 near Tehran after a crash that killed 176 (Abedin Taherkenareh/EPA)

The Ministry of Foreign Affairs later said on its Telegram channel that he had been summoned over his “illegal and inappropriate presence” at the protests.

Iranian authorities are on standby for further demonstrations after the Revolutionary Guard admitted accidentally shooting down the Ukrainian jet shortly after take-off, killing all 176 people on board, including four Britons.

Earlier deputy foreign minister Seyed Abbas Araghchi said police had been unaware Mr Macaire was a diplomat and had arrested him as an “unknown foreigner”.

He said Mr Macaire was released within 15 minutes once he was able to speak to him on the telephone and confirm he was the ambassador.

Richard Ratcliffe, the husband of British-Iranian mother Nazanin Zaghari-Ratcliffe, who has been detained in Iran since April 2016, said Mr Macaire’s arrest is a “really bad sign for us”.

He told Sky News’ Sophy Ridge on Sunday show: “The arrest of the ambassador and the attempt to try and turn that into ‘this is a foreign plot, it’s the British organising the protest’ which is what Iranian Press TV has put out, it’s a really bad sign for us.”

Ms Zaghari-Ratcliffe is serving a five-year sentence over allegations, which she vehemently denies, of plotting to overthrow the Tehran government.

In an article for The Sunday Telegraph, written before Mr Macaire’s arrest, Mr Raab urged Iran to “come in from the cold” and resolve its differences with the west peacefully.

He said the “diplomatic door has been left ajar” for the regime in Tehran to end the isolation “choking” its economy.

Mr Raab said Britain and its European allies still hope to revive the Iran nuclear deal, despite US president Donald Trump’s insistence that it is dead.

However, he said the Iranians must end their pursuit of nuclear weapons, drop their support for terrorism, and release the foreign nationals held as “pawns in its nefarious diplomatic game”.

The downing of Ukrainian International Airlines Flight 752 came just hours after Iran launched a series of ballistic missile strikes on US bases in Iraq in retaliation for the killing of its top commander, General Qassem Soleimani, by an American drone.

The missiles failed to cause any casualties and Mr Trump indicated he would respond by tightening sanctions rather than with further military action.