U.S. Ambassador to the United Nations Nikki Haley has resigned and will be out of her top diplomatic post by the end of the year.

President Trump and Haley announced her departure in a rare Oval Office send-off, with both leaders describing Haley's exit as amicable and long-anticipated.

[READ: Nikki Haley's letter of resignation]

Trump said in televised remarks that Haley foreshadowed her exit about six months ago, and that he wanted an on-air goodbye to dispel speculation about an adversarial ouster.

"When you write it out on a piece of paper that, you know, 'Ambassador Haley will be leaving' and you say nice things, people say, 'What's going on?'" Trump said. "When you really think somebody's done a terrific job, I felt this was an appropriate way of doing it."

Other top Trump administration officials have been fired without ceremony before being shamed in the media.

In one notable contrast, Trump announced former Secretary of State Rex Tillerson's firing on Twitter in March. White House chief of staff John Kelly later denied Tillerson was fired on Twitter. Instead, Kelly told reporters in leaked off-record remarks, he fired Tillerson over the phone while he was sitting on an African toilet, suffering from diarrhea.

Like Tillerson, Haley and Trump differed on some foreign policy matters, including on policy and tone toward Syria and Russia. But they showered each other with compliments Tuesday.

Haley effusively praised the first family and said she's a "lucky girl" to have had the job of U.N. ambassador. Haley said she would not challenge Trump in the 2020 Republican presidential primary and that she would stump for Trump's re-election campaign.

"I can't say enough good things about Jared and Ivanka," Haley said. "Jared is such a hidden genius that no one understands. I mean, to redo the NAFTA deal the way he did. What I've done working with him on the Middle East peace plan, it is so unbelievably well done."

Trump accepted the former South Carolina governor's resignation after the pair discussed her departure during a White House visit last week, Axios reported. Haley told her staff Tuesday morning she said has done two years and it was time to move on, CNN reported.

The president touted the "incredible job" Haley had done, citing progress his administration has made with North Korea thanks to her help.

"Nikki Haley has been very special to me," Trump said, adding she was a "fantastic person" and that he hated "to lose" her.

[Also read: Here are the notable Trump aides who have left the administration]

Both Trump and Haley gave no indication of discord, but the abrupt announcement raised some eyebrows.

American Conservative Union chair Matt Schlapp, whose wife Mercedes Schlapp is White House director of strategic communications, said on Fox News after the news broke: "Unless this is a personal issue or health concern, which I hope is not the case, it's obviously very unusual for a significant and prominent person on the president's team to announce that she is leaving so close to an election. There is something to this story. Like everyone in America I want to know what it is."

Haley has been instrumental in implementing Trump's "America First" approach to foreign policy on the world stage, including withdrawing the U.S. from the U.N. Human Rights Council.

Haley described her working relationship with the president in an opinion piece for the Washington Post in September.

"Like my colleagues in the Cabinet and on the National Security Council, I have very open access to the president. He does not shut out his advisers, and he does not demand that everyone agree with him. I can talk to him most any time, and I frequently do," Haley wrote.

"If I disagree with something and believe it is important enough to raise with the president, I do it. And he listens," she said.

Trump said he expected to nominate Haley's replacement within three weeks.

"She's made it a very glamorous position," he said.

[More: Ivanka Trump to replace Nikki Haley? Speculation runs rampant after UN ambassador resigns]