The coming departure of Nikki Haley as U.S. ambassador to the United Nations has sparked a new round of competition inside the top ranks of the Trump administration — a contest not just for a job but also for greater influence and control over the direction of U.S. foreign policy in the second half of President Trump’s first term.

On Tuesday, Haley seemed to pull off what few senior Trump administration officials so far have been able to achieve: an honorable exit. How she did it could be a model for others looking to leave the Trump team with their dignity and political viability intact. Haley organized her departure with the White House, praised Trump in a joint news conference, promised (in writing) not to challenge his political interests and thereby was able to depart on her own terms. Defense Secretary Jim Mattis must be taking copious notes.

By orchestrating her exit as she did, Haley avoided the humiliation Trump heaped on Rex Tillerson (fired while  sitting on the toilet in Africa), H.R. McMaster (negotiated a planned departure with a promotion but got pushed out sans promotion after many leaks), Tom Bossert (did everything right but fell victim to bureaucratic assassination by national security adviser John Bolton) and Reince Priebus (fired by tweet and unceremoniously kicked out of the presidential motorcade).

But now the internal battle to replace Haley is on, and its result will tell us who has the upper hand in crafting foreign policy in what could be the last two years of the Trump administration.

Internally, two camps are emerging. Former deputy national security adviser Dina Powell seems to be the front-runner. She is close to Jared Kushner, Ivanka Trump and the others sometimes referred to derisively as the “West Wing Democrats.” A Goldman Sachs executive with State Department experience, she would enjoy support from those who seek a more Wall Street-friendly, trade-friendly, internationalist foreign policy going forward.

Powell is also said to have earned the trust of the president during her time in the White House and delivered Trump some significant wins, including the safe return of American hostages from Egypt and the administration’s close relationship with Egypt and the Arab Gulf States.

Bolton is expected to push for an alternative candidate, though it’s not yet clear who that would be. Bolton has been consolidating power and exerting increasing influence over decision-making regarding national security personnel, with the help of his skilled deputy Mira Ricardel. Bolton is said to want a conservative hawk, someone more in line with his plans to continue challenging international institutions and international agreements.

“Replacing Haley is the continuation of a struggle between Bolton and factions resistant to his brand of conservative foreign policy,” an administration official told me. “If Trump chooses someone more in the mold of Haley or Bolton himself, it’s a big win for Bolton. Someone like Dina Powell means other forces are reasserting their control of personnel for the next two years.”

Speculation around Bolton’s potential candidate centers on U.S. Ambassador to Germany Richard Grenell, a favorite of pro-Trump pundits who have already begun their public lobbying campaign. But Grenell’s confirmation for his current job was held up for months due to Senate Democrats’ concerns about his past undiplomatic behavior and derogatory remarks he made about women on Twitter. Since he has taken up his post in Berlin, Grenell’s aggressive style has angered his German hosts.

Bolton and Trump may favor that more arrogant approach, but Grenell’s confirmation process would be tortured and slow. If Democrats somehow take control of the Senate, it would be impossible. That’s likely why Trump threw cold water on the idea Tuesday afternoon, saying, “He’s doing so well in Germany. … Rather keep Ric where he is.”

There are plenty of other conservative hawks in Bolton’s sphere who could be candidates. Christopher Burnham served as undersecretary general for management of the U.N. during the George W. Bush administration, essentially the chief operating officer of the U.N. He’s also a successful business executive who has worked at the State Department, is liked by Trump and has been close to the administration since the transition. Robert O’Brien is the current State Department envoy for hostage affairs and worked with Bolton when Bolton was U.N. ambassador. He’s well respected and just recently cleared vetting. Other candidates may emerge.

Haley was always more of a neoconservative, like Vice President Pence, rather than a conservative hawk like Bolton and Secretary of State Mike Pompeo. But ever since the departure of more realist types such as Tillerson and McMaster, the Trump foreign policy team has been more aligned than ever before. They found enough common cause to push forward the Iran deal withdrawal, a new policy on China and a remarkably tough Russia policy that seemingly flies in the face of Trump’s own desire to improve U.S.-Russia relations.

Now Haley’s departure — and the expected departure of Mattis after the midterm elections — throws that dynamic into question. In any administration, personnel equals policy. But in the Trump administration, both personnel and policy are always moving targets. Trump’s choice will signal which way U.S. foreign policy is headed, and that’s why the battle lines are being drawn now.

Read more:

Josh Rogin: Trump’s new foreign policy team is looking a lot more Republican