The U.S. ambassador to Estonia has announced his resignation, saying he is taking the “honorable course” in the wake of President Donald Trump’s “inaccurate” slams against the European Union, Foreign Policy reported Friday.

“For the president to say the EU was ‘set up to take advantage of the United States, to attack our piggy bank,’ or that ‘NATO is as bad as NAFTA’ is not only factually wrong, but proves to me that it’s time to go,” James D. Melville Jr. wrote in a private Facebook post obtained by Foreign Policy.

Melville was quoting Trump’s comments Wednesday at a campaign rally in North Dakota.

Pres. Trump: "We love the countries of the European Union. But the European Union, of course, was set up to take advantage of the United States." https://t.co/WY5hUuaonz pic.twitter.com/KI2nyWTymU — ABC News (@ABC) June 28, 2018

Melville has worked as a diplomat for 33 years and been in Estonia since 2015. He has served under six presidents. Melville said he was already planning to retire, but will cut short his service and step down at the end of July over Trump’s comments.

He said in his post that a foreign service officer is “programmed to support policy,” and that if there “comes a point when one can no longer do so ... the honorable course is to resign.”

Melville said he leaves with “deep gratitude for being able to serve my nation with integrity for many years, and with great confidence that America, which is and has always been, great, will someday return to being right.”

A screenshot of Melville’s message was posted on the Estonian news outlet Eesti Ekspress.

“We love the countries of the European Union,” Trump said. “But the European Union, of course, was set up to take advantage of the United States, to attack our piggy bank.”

Story continues

(Photo: Screenshot/Eesti Ekspress)

Melville’s announcement comes less than two weeks before a critical NATO summit in Brussels and Trump’s planned meeting in Helsinki with Russian President Vladimir Putin. Fears are mounting that the president will repeat his performance at the Group of Seven summit and exacerbate tensions with long-time American allies.

The White House has not yet commented on Melville’s resignation or his Facebook message.

Also on HuffPost

Love HuffPost? Become a founding member of HuffPost Plus today.

This article originally appeared on HuffPost.