Speaking to journalists at the State Department, he said, "Everyone has a line that they will not cross".
"My instructors made clear that if I believed I could not do that, I would be honour bound to resign".
The letter goes on to say that he leaves the embassy "in good hands" and the United States relationship with Panama is "strong". In a letter, Feeley said his disagreement with the administration of President Donald Trump is the reason for his departure.
The State Department confirmed the departure, saying Feeley has made a decision to "retire for personal reasons, as of 9 March this year".
The reports of the resignation comes just hours after the U.S. ambassador to Botswana was summoned as disparaging remarks Trump is alleged to have made about Africa and Haiti which sparked worldwide furor.
John Feeley, 56, who worked at the State Department for almost 30 years, announced his resignation in a letter to the State Department.
According to reports, Feeley had told the State Department officials about his stepping down on December 27, 2017, and so, it is not a direct response to Trump's alleged use of the word "shithole" to describe certain nations, officials said. But Under-secretary of State Steve Goldstein seemed to confirm as much in comments to reporters on Friday.
But others have wrestled with staying, feeling unsure whether they're protecting USA influence or contributing to its erosion. He joined it in 1990, after serving as a Marine helicopter pilot, and has held diplomatic roles throughout the Americas.
Morale at the agency has flagged since Trump took office.
Mr. Feeley is a Career Minister in the Senior Foreign Service and one of the Department's leading Latin America specialists.
Contrary to some early speculation, Feeley tendered his resignation prior to Trump's reported comments (which the president denies making).