Nikki Haley on Tuesday resigned as U.S. ambassador to the United Nations, a surprising departure that deprives President Trump's foreign policy team of one of its most well-known and outspoken figures.

Haley, a former South Carolina governor and rising Republican star, was a forceful voice in pushing Trump's agenda at the U.N. but has also been unafraid to break with the president at key moments.

Sitting with Haley in the Oval Office, Trump announced she would leave at the end of the year and said she wanted to "take a break" from public service. Trump added that Haley let him know of her intentions six months ago.

"She's done a fantastic job and we've done a fantastic job together," Trump said.

Both Trump and Haley sought to portray her exit on friendly terms, even though there has been friction between the two dating back to the 2016 presidential race.

Haley has long been rumored to have her own ambitions for higher office, but she sought to downplay speculation she is setting herself up for her own presidential bid. She said she is "not running for 2020" and will support Trump's reelection.

"It's been eight years of intense time and I'm a big believer in term limits," she said of her service within South Carolina and the Trump administration. "You have to be selfless enough to know when you step aside and allow someone else to do the job."

It is unusual for a departing Trump administration official to have such a cordial send-off. In one of the more extreme examples, former White House chief of staff Reince Priebus was dismissed last year and parted ways with the staff on the tarmac at Joint Base Andrews.

Trump told Haley said "this is the right way to do it when you really think someone's done a terrific job" and added he would invite her back to the administration in any capacity.

"You can have your pick," Trump said.

The president said he intends to name a replacement for Haley in two to three weeks. Possible successors being speculated in Washington include Dina Powell, Trump's former deputy national security adviser who left the administration at the beginning of the year.

Haley hosted Powell in her home state last weekend.

Haley is seen as a stabilizing force in the administration, given her mainstream Republican credentials and views on foreign policy.

But she also championed Trump's efforts to take an adversarial stance toward the U.N. In June, she announced the United States' withdrawal from the United Nations Human Rights Council, saying the body was a "protector of human rights abusers and cesspool of political bias."

Haley rattled off a number of administration actions she said she was proud of, including the decisions to withdraw from the Iran nuclear deal and move the U.S. Embassy in Israel from Tel Aviv to Jerusalem.

Her departure was lamented by a number of Republicans in Washington, including sometime critics of Trump.

"[Haley] was a strong voice for the U.S. & for moral clarity at the U.N. America was blessed to have her representing us. We thank her & her family for their service to our country & the cause of freedom & #HumanRights," tweeted Sen. Marco Rubio (R-Fla.)

Haley had recently lost a few internal debates over policy, however, including on the decision to allow a record low number of refugees into the U.S. next year.

Other officials, namely Secretary of State Mike Pompeo and national security adviser John Bolton, have increased their clout, leaving Haley's standing within Trump's foreign policy team somewhat diminished.

The former governor was a sharp critic of Trump during his run for president, at one point warning his harsh rhetoric could lead the U.S. into war. That extended into his time in the White House - in December 2017 she said women who accused Trump of sexual misconduct "should be heard."

Many in Washington speculated that Haley was the author of an anonymous op-ed in The New York Times by a person who claimed to be an administration official working to undermine Trump.

Haley denied she was the author and later wrote her own op-ed in The Washington Post criticizing the Times piece.

"I don't agree with the president on everything. When there is disagreement, there is a right way and a wrong way to address it. I pick up the phone and call him or meet with him in person," she wrote.

She also portrayed Trump as a leader who is willing to tolerate internal dissent and listen to opposing views.

Haley's exit, which comes just weeks before the November midterm elections, will be viewed as a sign of tumult in the administration at an inopportune moment for the White House. Her abrupt exit follows a major victory for Trump on the hard-fought confirmation of Brett Kavanaugh to the Supreme Court.

It reportedly blindsided many in the administration, including Bolton and White House chief of staff John Kelly.

But Trump said he already has a long list of people interested in Haley's post.

"I think it's become maybe a more glamorous position than it was two years ago," Trump said. "Maybe, I wonder why, but it is. She's made it a very glamorous position."