U.S. Ambassador to the United Nations Nikki Haley announced Tuesday she will resign at the end of the year, a surprising move that caught even top Trump administration officials by surprise.

Speaking to reporters with President Donald Trump in the Oval Office, Haley said after being governor of South Carolina and U.N. ambassador it was time to open the door for someone else.

"It was the honor of a lifetime," she said. "Look at the past two years. Look at what has happened with the United States. Countries may not like what we do, but they respect what we do.

"My goal is that we make sure everything is in a good place for the next ambassador to come in."

Trump credited Haley for making progress on North Korean denuclearization and pushing Iran toward making a new nuclear deal with the United States, since the administration withdrew from the 2015 Obama-era agreement.

"We are respected again, I can tell you," Trump told reporters. "[North Korea] looked like a real problem. Iran looked like a real problem -- there was a question of when they would take over the Middle East. What a difference between now and then."

Trump said Haley told him six months ago she would resign at the end of 2018.

In the Oval Office, Haley refuted speculation that she might run for political office in 2020, saying she will be campaigning for Trump's re-election.

Tuesday's announcement came 19 months after Haley was appointed to the U.N. post, and two weeks after the U.N. General Assembly meeting in New York City.