The US ambassador to Estonia Jim Melville is resigning over Donald Trump's comments about European Union.

The U.S. ambassador to Estonia Jim Melville will retire at the end of July following a series of provocative comments US President Donald Trump made about the European Union.

The U.S. ambassador to Estonia wrote in a private Facebook post that he decided it was time for him to leave after Trump’s comments on how the EU was “set up to take advantage of the United States, to attack our piggy bank“ and that “NATO is as bad as NAFTA.”

In a statement, a State Department spokesperson confirmed Melville's departure.

Jim Melville has served as ambassador since 2015.

Melville is the third ambassador in the past year to retire early.

Melville's resignation comes at a time of acutely heightened tension in an alliance that, before Trump's election, had been one of the most solid, reliable and interconnected US relationships.

But Trump's attacks on NATO members, his trade tariffs against EU nations, his rejection of the Iran nuclear deal and the Paris climate agreement and his attacks on leaders such as German Chancellor Angela Merkel have cast a pall over US ties to Europe.