In the winter of 2016, Donald Trump was roaring through the primaries, and Mike Pompeo was determined to stop him. Pompeo, a little-known congressman from Wichita, helped persuade Marco Rubio to make a late stand in Kansas. Like many Republicans in Congress, Pompeo believed that Rubio had the national-security knowledge and the judgment to be President, and Trump did not. Urged on by Pompeo, Rubio’s team pulled money out of other states to gamble on winning the Kansas caucus. It was one of the few remaining contests in which Rubio still hoped to beat Trump, who, he said, was a “con artist” about to “take over the Republican Party.”

On March 5th, Trump and Senator Ted Cruz, of Texas, arrived in Wichita for the caucus. Rubio left his closing argument to Pompeo, who told the crowd at the Century II arena, “I’m going to speak to you from the heart about what I believe is the best path forward for America.” An Army veteran who finished first in his class at West Point, Pompeo cited Trump’s boast that if he ordered a soldier to commit a war crime the soldier would “go do it.” As the audience booed, Pompeo warned that Trump—like Barack Obama—would be “an authoritarian President who ignored our Constitution.” American soldiers “don’t swear an allegiance to President Trump or any other President,” Pompeo declared. “They take an oath to defend our Constitution, as Kansans, as conservatives, as Republicans, as Americans. Marco Rubio will never demean our soldiers by saying that he will order them to do things that are inconsistent with our Constitution.” Listening backstage, Trump demanded to know the identity of the congressman trashing him. A few minutes later, Pompeo concluded, “It’s time to turn down the lights on the circus.”

Pompeo’s stinging rebuke of Trump got barely a mention in the local press, and Rubio finished third in Kansas. “We got smoked,” a former top Rubio campaign aide told me. Days later, Rubio’s campaign was over. In May, Trump secured the delegates needed for the nomination, and Pompeo reluctantly joined the rest of Kansas’s congressional delegation in endorsing him. Still, Pompeo had told the Topeka Capital-Journal, in April, that Trump was “not a conservative believer,” and, a few weeks later, he said, on CNN, “A lot of his policies don’t comport with my vision for how I represent Kansas.”

At that point, Pompeo had never met Trump. Like many Republicans who called Trump a “kook,” a “cancer,” and a threat to democracy before ultimately supporting him, Pompeo disagreed with much of Trump’s platform. He took issue in particular with Trump’s “America First” skepticism about the United States’ role in the world. Pompeo was a conservative internationalist who had been shaped by his Cold War-era military service, and he remained a believer in American power as the guarantor of global stability. Yet, after Trump won the Presidency, Pompeo sought a post in his Administration and did not hesitate to serve as his C.I.A. director. In 2018, after Trump fired Secretary of State Rex Tillerson, by tweet, Pompeo happily replaced him as America’s top diplomat.

Pompeo, an evangelical Christian who keeps an open Bible on his desk, now says it’s possible that God raised up Trump as a modern Queen Esther, the Biblical figure who convinced the King of Persia to spare the Jewish people. He defines his own job as serving the President, whatever the President asks of him. “A Secretary of State has to know what the President wants,” he said, at a recent appearance in Washington. “To the extent you get out of synch with that leader, then you’re just out shooting the breeze.” No matter what Trump has said or done, Pompeo has stood by him. As a former senior White House official told me, “There will never be any daylight publicly between him and Trump.” The former official said that, in private, too, Pompeo is “among the most sycophantic and obsequious people around Trump.” Even more bluntly, a former American ambassador told me, “He’s like a heat-seeking missile for Trump’s ass.”

Pompeo’s transformation reflects the larger story of how the Republican Party went from disdaining Trump to embracing him with barely a murmur of dissent. This account of how Pompeo became the last survivor of the President’s original national-security team and his most influential adviser on international affairs is based on dozens of interviews in recent months with current and former Administration officials, U.S. and foreign diplomats, and friends and colleagues of Pompeo’s; the Secretary did not answer repeated requests for comment.

Thirty-one months into the Administration, the relationship between Trump and Pompeo, born in derision and remade in flattery, has proved to be surprisingly durable. Trump often gushes about Pompeo, even as he has berated his hawkish national-security adviser, John Bolton, for taking similar positions. “I argue with everyone,” Trump told a reporter. “Except Pompeo.”

Fifty-five, burly, and barrel-chested, Pompeo lives with his second wife, Susan, and their golden retriever, Sherman, in a rented house on the grounds of a military base across the street from the State Department. A film buff and an AC/DC fan, he seems modest and approachable in settings where he’s comfortable. When challenged, especially about the President, he gets testy and red in the face. He favors baggy gray suits and close-cropped gray hair. Trump, who often talks about whether someone “looks the part,” has made a point of calling out Pompeo’s unglamorous presence. At a recent appearance in South Korea, he summoned Pompeo to the stage with his daughter Ivanka, referring to them as “beauty and the beast.”

Pompeo’s background bears little resemblance to that of recent Secretaries of State, all of whom came to the job after long careers in public life and with extensive international experience. Pompeo, in contrast, has had a “meteoric rise,” as his friend Steve Scalise, the House Republican Whip, told me. A little more than a decade ago, he was unknown not only in Washington but also in his adopted home state, where he had just lost his first campaign, placing third in a three-way race to become chairman of the Kansas Republican Party. Trump often touts Pompeo’s credentials as a top student at West Point and at Harvard Law School, but in six years as a member of Congress he never chaired a subcommittee or faced a genuinely competitive election, and he served just over a year at the C.I.A. He spent much of his career running a struggling Wichita aviation company. Pompeo’s disclosure forms reveal that he is the poorest member of Trump’s Cabinet, listing family assets worth roughly, in 2018, between two hundred thousand and seven hundred and fifty thousand dollars.

Watch “The Backstory”: Susan B. Glasser reports on how Mike Pompeo reinvented himself and went from an obscure congressman to Trump's most influential adviser on international affairs.

Born in 1963, Pompeo was one of three children in a working-class family in Southern California. His father, Wayne, was a Navy radioman in the Korean War. His mother, Dorothy Mercer, was one of ten children of small-town Kansas pool-hall owners. In conservative Orange County, Wayne was a passionate liberal, according to two sources who heard this from the future Secretary. Pompeo does not speak publicly about his political disagreements with his father, but they began early on: he has said that, as a teen-ager, he read Ayn Rand’s “The Fountainhead,” and became a staunch conservative. The valedictorian of his public high school, he was nominated for West Point by his congressman, Bob Dornan, a fiery hard-right favorite of the defense industry. “That should give you a good idea of where I am coming from politically if ‘B-1 Bob’ chose me for West Point,” Pompeo told the conservative magazine Human Events, in 2011.