President-elect Donald Trump has picked Rex Tillerson as his nominee for secretary of state. Here's what you need to know about Tillerson. (Thomas Johnson,Victoria Walker,Danielle Kunitz/The Washington Post)

Donald Trump sat in his office at Trump Tower on Dec. 2 facing the most important choice of his transition to the presidency, and his indecision had set off a war among his top aides.

Some favored Mitt Romney, who had trashed Trump during the campaign. Many wanted the ultimate loyalist, Rudolph W. Giuliani. Others preferred Sen. Bob Corker (R-Tenn.) or retired Gen. David Petraeus. Trump, who hated being pressured when making important decisions, insisted that he needed more time. He seemed to have misgivings about all of them.

Then, by happenstance, Trump welcomed into his office a man who has served presidents of both parties, Robert M. Gates. Trump asked his guest, a former CIA director and former defense secretary, what he thought of the four candidates. After Gates ran through his thoughts, it seemed that Trump was “looking for a way out,” a person familiar with the session said.

Trump asked whether there was someone else to consider.

“I recommend Rex,” Gates told Trump, referring to Rex Tillerson, the chief executive of ExxonMobil. Gates said in an interview that he had not gone to the meeting intending to recommend Tillerson, and he did not recommend anyone else. Separately, on the previous day, former secretary of state Condoleezza Rice had proposed Tillerson to Vice President-elect Mike Pence. Rice and Gates, who run a consulting firm that counts ExxonMobil as a client, had jointly concluded that Tillerson might give Trump a fresh alternative.

Trump “seemed intrigued,” Gates said. “It was not something he had considered.”

The result was an unexpected decision, nominating as the country’s top diplomat a multinational corporate chief executive who had been on nobody’s shortlist for the job. It provided an object lesson in the decision-making process and leadership style of a president-elect who has never worked in government and is applying his un­or­tho­dox style to decisions that could shape the world.

Names were floated, aides took sides, and Trump grew increasingly disenchanted. Many Trump traits were in evidence, from the reality-show-like parade of candidates, to the dismissal of onetime allies, to the efforts by aides to influence him through tweets and television appearances.

The process reflected Trump’s refusal to be rushed or pushed and showed how he was not necessarily beholden to his strongest supporters or inclined to dismiss his most strident critics, on the right terms, yet yearned for a personal connection. And he did not seem worried about the potential for a difficult confirmation, even as Republican lawmakers began to speak up, questioning Tillerson’s perceived close ties to Russia.

This account is based on interviews with several participants in the deliberations and others close to the contenders, including some who spoke on the condition of anonymity to describe sensitive internal conversations.

Two days after Trump met with Gates, as Sunday talk show guests speculated about Trump’s choice, those closest to the decision had come up with a scorecard.

Giuliani, the former New York mayor, was in first place, Romney was just behind at “1A,” and ­Petraeus was “in the mix.” Tillerson remained a contingency, but his stock was starting to rise.

Here are the people Trump has chosen for his Cabinet

Giuliani had been one of Trump’s most stalwart defenders during the campaign, and his name was pushed particularly hard by Trump allies such as former House speaker Newt Gingrich.

But Trump became increasingly concerned about the 72-year-old Giuliani’s fitness for the job. Trump confided to friends that he thought that Giuliani, two decades removed from his heyday running New York, was past his prime and might not have the stamina or discipline to travel the globe and negotiate delicate matters.

“He was hearing a lot of concerns about Rudy,” one Trump friend said, speaking on the condition of anonymity.

Giuliani and an associate did not respond to requests for comment.

Over Thanksgiving, as Trump retreated with his family to Mar-a-Lago, his Palm Beach, Fla., resort, his focus turned to an unlikely pick: Romney. The 2012 Republican presidential nominee had been one of Trump’s harshest critics, calling him a “fraud” and a “phony.” Trump had dismissed Romney as a “choker” who walked “like a penguin.”

But one of Romney’s closest friends, Stephen Pagliuca, the co-owner of the Boston Celtics and a former colleague at Bain Capital, told Romney that he should consider the job while telling his friends working for Trump that they should consider the idea, too.

The Romney courtship began with a congratulatory phone call from the former Massachusetts governor to Trump. Trump missed the call, and Pence wound up returning it. To Romney’s surprise, Pence asked him to come to New York. Then Trump called and also asked Romney to meet. Romney indicated that the only position he would like to be considered for was at State, according to an associate.

Those in attendance at the first meeting, held at Trump’s golf course in Bedminster, N.J., included Trump and Pence, Republican National Committee Chairman Reince Priebus, political adviser Stephen K. Bannon, Trump son-in-law Jared Kushner and one of Trump’s sons, Eric. Romney and the president-elect also spoke privately that day for about 20 minutes, then later on the phone several times, eventually agreeing to meet for dinner Nov. 29 in New York.

Romney’s motivation, according to three people close to him, was sparked by a sense of duty. Since his unsuccessful run for the White House, Romney has devoted much of his intellectual energy to foreign policy and national security issues.

Trump liked the idea of reconciling with a former enemy. As one longtime Trump associate noted, Trump had a history in his businesses of feuding bitterly with competitors and others, only to join forces with them. Given their histories, a rapprochement between the two was not so unthinkable.

After their meal at the swanky Jean-Georges restaurant, Romney lavished praise on Trump, saying he had been “very impressed” by Trump’s vow to be an inclusive president. A Trump friend said the president-elect, who did not join Romney in talking to reporters afterward, enjoyed watching his dinner partner appear to grovel for the post.

Some of those in Trump’s orbit who opposed the Romney selection presented the process as a punishment of sorts. Longtime Trump associate and provocateur Roger Stone later said in an interview with Alex Jones on Jones’s radio show — which has pushed a variety of conspiracy theories — that the president-elect strung Romney along to “torture him.”

Trump was hearing from aides and supporters upset by the prospect of handing such a big job to Romney. Campaign manager Kellyanne Conway took to the Sunday news shows to describe a Romney pick as a betrayal of Trump’s base.

Trump was seriously considering Romney. He had a request, according to a close Romney ally: an apology.

Romney, author of a book called “No Apology,” refused, the ally said. He said he wanted to be “forward looking,” according to the Romney associate. The associate said that Romney had hoped his complimentary comments about Trump after the dinner would ­suffice and that he didn’t want to “re-litigate” his criticism during the campaign.

Trump spokesman Jason Miller disputed the account of the apology request, saying it was “not true in any way” and “completely false.” Miller did not respond to other questions about the selection process.

Romney declined an interview request. In an emailed statement, he said: “I was indeed very critical of Mr. Trump during his campaign. But now he has been elected president and accordingly, if I could have helped shape foreign policy to protect the country I love, I would have been more than willing to do so.”

A second stumbling block was that Romney and Trump differed on Russia. Romney has called Russia the top geopolitical foe of the United States, while Trump has said he wants to have close ties with Moscow. Romney knew he was at odds with Trump but had hoped to provide balance in the administration, the associate said.

“There were differences in views, and I’m confident that was a worry to both of them,” said former Utah governor Mike Leavitt, who oversaw transition planning for Romney four years ago.

Romney gradually fell from his 1A position. So, too, had Giuliani fallen. On Dec. 9, five days after being categorized as Trump’s top choice, Giuliani said he was taking himself out of contention. The Trump team was concerned about not only Giuliani’s stamina but also his ego. One Trump associate said Giuliani had refused to consider heading the Homeland Security or Justice department. Only State would do.

“He got out too far in front of Trump,” the Trump associate said. “He became the star. Trump doesn’t like more than one star. . . . When you give an ultimatum that ‘I will only take one position,’ it doesn’t work.”

Appearing that day on Fox News, Giuliani tried to take down Romney with him, saying the former Massachusetts governor had “gone over the line” bashing Trump and shouldn’t be considered.

Trump’s list of candidates continued to narrow. Corker, the Tennessee Republican who heads the Senate Foreign Relations Committee, met with Trump on Nov. 29, but his role appears to have been as a backup choice.

Then, in a surprising twist, Petraeus was ascendant. The retired general and former CIA director, who once was mentioned as a possible presidential candidate, had fallen after pleading guilty to mishandling classified information, which he had provided to his biographer and mistress, Paula Broadwell. Trump, who had been harshly critical of Democratic nominee Hillary Clinton for her handling of classified information, did not seem to see Petraeus’s action as disqualifying him for consideration. A number of Petraeus’s fellow generals lauded his intelligence and loyalty. “Just met with General Petraeus — was very impressed!” Trump tweeted.

Soon, however, news accounts reported that Petraeus was still on probation. He would have to notify his probation officer of his travel plans. His home, car, cellphone and computer would be subject to search without a warrant. Trump did not explain his decision to rule out the retired general, much to the frustration of Petraeus’s allies.

“Only the president-elect and transition folks can say why he fell out of the mix,” former Petraeus spokesman Steve Boylan said. “I don’t know if it was the news articles, or anti-Petraeus people taking a stance on it. I’m not aware of anything specific that would have said, ‘No, you are no longer being considered.’ ”

So it was that Trump, who had devoted more time to this decision than any other, prepared to meet with Gates on Dec. 2, thinking about the possibility of expanding his search. Gates wasn’t even supposed to be there. A day earlier, he met with Trump’s pick for national security adviser, Lt. Gen. Michael T. Flynn, who proposed a meeting the next day with Trump.

After Gates went through the pluses and minuses of the four candidates, and Trump asked about other possibilities, Gates made his pitch for Tillerson. It was an unexpected move. Trump didn’t know the ExxonMobil CEO.

Gates initially knew Tillerson through their shared work with the Boy Scouts of America. They later had a work connection when ExxonMobil became a client of RiceHadleyGates, an international consulting firm.

As word leaked that Tillerson was the likely pick, a chorus of critics noted that he had been close to Russian President Vladimir Putin, who had worked with ExxonMobil on energy deals. The company had an interest in closer relations, given that some of its operations in Russia are on hold because of economic sanctions imposed after the country annexed Crimea and supported insurgents in eastern Ukraine. Tillerson was awarded the Kremlin’s Order of Friendship in 2013. Sen. John McCain (R-Ariz.) questioned Tillerson’s relationship with Putin, saying on CNN that “I don’t see how anybody could be a friend of this old-time KGB agent.”

But Gates said Tillerson’s experience doing business in difficult parts of the world is an asset, and not because he has any cozy relationships with despots.

“It would be a mistake to confuse a friendly relationship with friendship. Rex is a very tough-minded realist” who well understands Putin and his own position and motives, Gates said.

Gates had seen the inspirational and motivational side of Tillerson when the executive was talking to Boy Scouts and volunteers.

“If you want to understand Rex Tillerson, and it may be a corny thing to say, but you’ve got to understand that he’s an Eagle Scout,” Gates said.

Rice, who was also talking up Tillerson, had met the CEO through their mutual membership at Augusta National Golf Club, and the two had played golf together. They also had talked extensively about international politics, whether the Middle East, Russia, Indonesia or Latin America.

Trump, who has been drawn to fellow executives for Cabinet picks, liked what he heard. He invited Tillerson to Trump Tower, and the two met on Dec. 6 and again on Dec. 10, after which Trump offered the State Department job.

A potentially bruising confirmation hearing is pending, but Trump was confident his un­or­tho­dox process had worked. He seemed to relish the battle ahead.

Typically, Trump chose Twitter to announce his decision Tuesday. He had chosen, he tweeted, “one of the truly great business leaders of the world.”

Read more:

From enemies to potential allies: How the Trump-Romney divide began to heal

Trump recruits army of chief executives to battle with the system in Washington

Trump praises Tillerson’s ‘friendly’ relationships with foreign leaders ‘we don’t get along with’