Iranian President Hassan Rouhani told foreign powers to withdraw their forces from the Middle East, warning they "may be in danger" if they remain in the region.

"Today, the American soldier is in danger, tomorrow the European soldier could be in danger," Hassan Rouhani said in televised remarks on Wednesday, without elaborating.

Rouhani's comments mark the first time he has threatened European countries amid heightened tensions with the United States.

More:

The comments came a day after the United Kingdom, France and Germany challenged Tehran over breaking limits of a major nuclear deal signed in 2015 between Iran and six world powers.

The European nations announced on Tuesday that they triggered the dispute mechanism provided for in the landmark agreement in order to force Tehran to honour its commitments under the accord, formally known as the Joint Comprehensive Plan of Action (JCPOA), from which US President Donald Trump unilaterally withdrew in 2018.

Friction in the region escalated in recent months after a series of attacks in the Gulf region that Washington blamed on Iran and its proxies, over Iranian denials.

Fears of an all-out war emerged earlier in January after a US air strike killed top Iranian military commander Qassem Soleimani in Baghdad, prompting retaliatory Iranian missile strikes against US targets in Iraq.

European forces have been deployed alongside American troops in Iraq and Afghanistan. France also maintains a naval base in Abu Dhabi, the capital of the United Arab Emirates, while Britain has opened a base on the island nation of Bahrain.

European Commission spokesman Peter Stano told reporters that officials were aware of the threats, but the European Union had no plans to leave Iraq.

Italian Defense Minister Lorenzo Guerini told lawmakers his government has plans to increase Rome's troop levels in the Strait of Hormuz, the narrow mouth of the Gulf through which 20 percent of all oil passes.

German Defence Minister Annegret Kramp-Karrenbauer, meanwhile, made an unannounced visit on Wednesday to the Azraq base in Jordan, where German troops serving in the fight against the ISIL (ISIS) armed group are based. Germany wants to resume training Iraqi forces.

Nuclear deal

Separately, Rouhani also dismissed a proposal for a new "Trump deal" to replace the JCPOA, saying it was a "strange" offer and criticising the US president for breaking promises.

UK Prime Minister Boris Johnson, who has praised Trump as a great dealmaker, called on Tuesday for Trump to replace the Iranian nuclear deal with his own new pact to ensure the Islamic republic does not get an atomic weapon - Iran has pledged that it does not seek the bomb.

"Prime Minister of the United Kingdom, @BorisJohnson, stated, 'We should replace the Iran deal with the Trump deal,'" Trump said in a tweet. "I agree!"

Trump in May 2018 withdrew the US from the deal, in which Tehran had agreed to curb its nuclear programme in exchange for a reprieve from international sanctions. The US has since reimposed a range of sanctions on Tehran and called for negotiations over a new accord.

In response to the US move, Tehran has begun uranium enrichment again and enhancing its nuclear programme, while also accusing the European parties to the deal of failing to live up to their own commitments to provide economic relief to Tehran.

Reporting from Tehran, Al Jazeera's Assed Baig said Rouhani urged the European powers to live up to their commitments in the nuclear deal and not give in to US demands.

"Rouhani stressed that all the steps Iran took in response to the US withdrawal from the deal were reversible," Baig said.

"He said this is a good deal for Iran, but Tehran would keep fulfilling its commitments only if European parties to the deal do so as well."

Also on Wednesday, Iranian Foreign Minister Mohammad Javad Zarif accused the European parties to the deal of violating its terms.

"They are not buying oil from us, all of their companies have withdrawn from Iran. So Europe is in violation," Zarif told a conference in New Delhi, saying the future of the deal now "depends on Europe".

He added that the European Union "is the largest global economy. So why do you allow the United States to bully you around?"

Zarif also said the US killing of Soleimani had served only to strengthen the Islamic State of Iraq and the Levant (ISIL, or ISIS) group.

"I think the war against Daesh [ISIL] just suffered a major setback, and Daesh just won a major victory," he said.

He also implied that the crisis sparked by the killing of Soleimani had contributed to Iran's accidental shooting down of a Ukrainian airliner on January 8, killing all 176 people on board.

"Why did it happen? Because there was a crisis. People make mistakes, unforgivable mistakes, but it happened in the time of the crisis," Zarif said.

Later on Wednesday, Iranian state media said the British ambassador to Iran had left the country, amid a dispute over his attendance at an anti-government demonstration. The state-run IRNA news agency reported that Robert Macaire had left Iran after being given "prior notice".

The British foreign office said that Macaire's trip to London was "routine, business as usual" and was pre-planned.

"It is quite normal for our ambassadors to come back to London to have meetings here," a foreign office spokesman said.