The US ambassador to Panama has resigned from his post, telling the State Department that he can no longer serve under President Trump, according to reports.

John Feeley informed the State Department of his intention to step down early Thursday — before Trump reportedly referred to Haiti and African nations as “shithole countries,” a Panamian news outlet reported.

“As a junior foreign service officer, I signed an oath to serve faithfully the president and his administration in an apolitical fashion, even when I might not agree with certain policies,” Feeley said in his resignation letter, Reuters reported.

“My instructors made clear that if I believed I could not do that, I would be honor bound to resign. That time has come,” he added.

The State Department confirmed the departure, saying Feeley has decided to “retire for personal reasons, as of 9 March this year.”

Panama’s DiaaDia reported his resignation before the Washington Post broke the news about Trump’s offensive remarks in an Oval Office meeting with senators about immigration.

Feeley was nominated to the diplomatic post by then-President Barack Obama in July 2015.

The Marine Corps veteran flew amphibious assault helicopters in and over Lebanon in the mid-1980s following the 1983 bombing of the Marine barracks in Beirut.