WASHINGTON — During her two years serving in the Trump administration, Nikki R. Haley, the former ambassador to the United Nations, managed to toe a tougher line on Russia than her boss, while also never straying from his good graces.
“We don’t trust Russia. We don’t trust Putin,” Ms. Haley said in an interview in July 2018, days after Mr. Trump met with the Russian president, Vladimir V. Putin, in Helsinki, Finland. “They’re never going to be our friend.”
By the time Ms. Haley left the administration nearly a year ago, she seemed to have perfected an almost impossible dance: distancing herself from some of the president’s most criticized positions while staying publicly loyal. She managed to leave both on her terms and on good terms with the president.
It was a balancing act that did not go without notice, and Ms. Haley, a woman of color and a former governor of South Carolina, was widely seen as preserving her options for a return to politics, perhaps as a post-Trump presidential candidate.
Last summer, she challenged the president once more after he had trumpeted the fact that the Baltimore home of Representative Elijah E. Cummings, a critic of Mr. Trump, had been broken into.
“This is so unnecessary,” Ms. Haley wrote on Twitter in August, infuriating the president, according to aides.
But now, Ms. Haley appears to have made the political calculation to go all in supporting the president, rather than defining herself in contrast to him.
In a media blitz timed to the release of her new book, “With All Due Respect: Defending America With Grit and Grace,” Ms. Haley has consistently echoed White House talking points about how there is no case for impeachment and unequivocally defended Mr. Trump’s character.
“In every instance I dealt with him, he was truthful, he listened and he was great to work with,” Ms. Haley told NBC’s Savannah Guthrie.
In her book, Ms. Haley does not criticize the president, but does take on two targets who have fallen out of favor with him, and with whom she clashed repeatedly: John F. Kelly, the former chief of staff, and Rex Tillerson, the former secretary of state.
She praises the president as a leader who always treated her with respect and describes an honest relationship in which he would sometimes change course based on her counsel.
In describing the announcement of her resignation in October 2018, when Mr. Trump praised her for her service, she writes that the president was “the man I’d seen many times, the man he too often doesn’t let the country see.”
She even tries to explain his continuing flattery of Mr. Putin, describing a conversation with him after the Helsinki meeting.
“To his credit,” she writes, “the president soon issued additional remarks, saying he had misspoken.” She adds: “I was glad he made that clarification, and I understood what he had been trying to do. He was trying to keep communication open with Putin.”
She also credits Mr. Trump with learning from the experience of Charlottesville, and handling synagogue shootings in Pittsburgh and near San Diego “with great sensitivity and appropriateness.”
Ms. Haley’s loyalty to Mr. Trump’s view of the world has been rewarded with a presidential endorsement. “Make sure you order your copy today, or stop by one of her book tour stops to get a copy and say hello. Good luck Nikki!” Mr. Trump wrote on Twitter.
For Ms. Haley, an Indian-American Tea Party activist who became a two-term governor of South Carolina known better as a voice of moderation on racial issues in the South, the reaction to her tweet about Mr. Cummings was a rude reminder of how she risks losing the Trump base when she puts distance between herself and the president.
Mr. Trump, aides said, wanted to respond to her himself, but was talked out of doing it. Instead, Kellyanne Conway, a top adviser who is close with Vice President Mike Pence, shot back at Ms. Haley in a tweet that was sanctioned from the top. “THIS is so unnecessary Trump-PENCE2020,” Ms. Conway wrote, an allusion to the rumors that Ms. Haley had been positioning herself to replace Mr. Pence on the ticket in 2020.
Ms. Haley remains close with the president’s daughter Ivanka and her husband, Jared Kushner, and they warned her to be more careful talking about Mr. Trump, according to two people familiar with the conversation. A spokeswoman for Ms. Haley said she never received such a warning.
Her subsequent pivot can be seen as a recognition of the reality confronting anyone contemplating a future in today’s Republican Party — there is little future after distancing yourself from Mr. Trump.
“It is Trump’s party today and, more likely than not, it will be Trump’s party 10 years from now,” said Kevin Madden, a political strategist and former adviser to Mitt Romney’s presidential campaign. “Trump will cast a long shadow over the party’s profile and will be a litmus test for the party’s most active base voters for years to come.”
For Republicans like Ms. Haley, Mr. Madden said the relationship with Trumpism would continue to be a balancing act.
“Stray too far and you run the risk of inviting scorn from his biggest defenders,” he said. “Go lock step with him and, as we’ve seen with the 2018 midterm test and the 2019 contests in key states like Virginia, the potential is there to alienate voters in suburbs who are making and breaking elections right now.”
Ms. Haley has been relatively removed from public life in the year since she left the administration. She joined the board of Boeing and is reportedly getting paid $200,000 a speech on the speaking tour.
But her forays into politics show someone who is tacking toward Mr. Trump, while leaving herself room for daylight between them in the future.
She has held a fund-raiser for the president and plans to do more, according to an aide. Ms. Haley, who still lives in New York City but plans to return to South Carolina after her son graduates from high school, has also started a nonprofit organization called Stand for America.
The group’s website describes America’s prosperity being threatened by “socialist schemes” of higher taxes, regulations and “unsecure borders,” echoing the language and themes of Mr. Trump’s own re-election campaign. She has campaigned for Republicans like Senator Joni Ernst of Iowa and Senator Cory Gardner of Colorado.
But she also appears to be stirring the pot on Twitter in a way that is intended to grab Mr. Trump’s attention and stay in the news.
On Monday, she targeted George T. Conway III, the outspoken, Trump-hating husband of Ms. Conway, who has drawn the president’s own ire.
“George Conway is the last person that can call someone ‘trash’. #Pathetic,” Ms. Haley wrote on Twitter, criticizing Mr. Conway for an attack on Representative Elise Stefanik, Republican of New York, who emerged during the first week of televised impeachment hearings as a moderate turned Trump defender.
“You’ll say anything to get the vice-presidential nomination, won’t you?” Mr. Conway fired back.
Ms. Haley, who declined to comment for this article, has in the past denied that she is seeking to replace Mr. Pence.
But White House advisers loyal to Mr. Pence have long faulted Ms. Haley for stoking the rumors that she could potentially replace Mr. Pence on the 2020 ticket — something they see as beneficial to an out-of-office politician who needs a way to stay relevant until the next presidential race.
Some have noted with frustration that it was Mr. Pence who first advocated Ms. Haley joining the administration, even though she had been tacitly critical of Mr. Trump during her 2016 response to President Barack Obama’s final State of the Union address and had supported Senator Marco Rubio of Florida during the 2016 Republican primary.
For now, friends said, with plenty of time for another pivot down the line, supporting Mr. Trump makes sense.
“Having that tweet from Donald Trump is going to be very, very important, promoting the book,” said Bakari Sellers, the former South Carolina state legislator who ran unsuccessfully for lieutenant governor and is now a CNN commentator. “She got what she wanted.”
Mr. Sellers, a Democrat who said he considered Ms. Haley a friend, said that in her balancing act he saw someone who had plenty of time to recalibrate. Ms. Haley, he predicted, would have a longer political story to tell.
“Donald Trump is going to be a footnote in her political career,” Mr. Sellers predicted. “It won’t be defining.”