In January 2020, shortly before the world shut down, Jack Dorsey invited a special guest to speak at Twitter’s companywide offsite in Houston: his favorite tweeter, Elon Musk.

The short FaceTime conversation, which was projected onto a giant video screen as thousands of employees looked on, was oddly foreshadowing. Dorsey jokingly asked Musk if he wanted to run Twitter, and Musk complained that he encountered too many bots on the service. Dorsey ended the discussion with effusive praise.

“Elon, we appreciate you so much for everything you’re doing around climate change and pushing the boundaries of exploration and human potential,” he said from the stage. “So thank you very much, and thank you for using us. We love you.”

There are a lot of reasons why Musk, the richest person in the world, ultimately bought Twitter for $44 billion in April of 2022. Dorsey’s resignation a few months earlier to focus on Bitcoin had created an opening; Musk’s disdain for Twitter bots had provided a challenge. But as I spent time reporting on the acquisition for my new book, Battle for the Bird, I realized that Dorsey’s admiration for Musk may have been the secret ingredient that put this whole thing into motion.

Dorsey’s feelings toward Musk were not really a secret when the deal first materialized. He’d been open about how much he enjoyed Musk’s brash and, at times, legally perilous tweets, and obviously he felt that Musk was important enough to provide a pep talk to all of Twitter’s employees. (A similarly scheduled interview arranged two years prior had been canceled at the last minute.) Dorsey even visited Musk at SpaceX’s launch facility in Texas, known as Starbase, just a few months before the deal came together.

What I didn’t appreciate until digging into the story, though, was how much Dorsey seemed to be swaying things with Musk behind the scenes as the billionaire Tesla boss weighed his options. After Musk ominously asked in a March 2022 tweet whether there needed to be an alternative to Twitter, Dorsey quickly sent him a private message. “Yes, a new platform is needed. It can’t be a company,” Dorsey wrote, as revealed in court documents later made public. “This is why I left.” Turns out the Twitter co-founder no longer had faith in the company he’d spent the better part of a decade running.

What followed over the next few weeks were several more texts and, eventually, calls between Musk and Dorsey that set the groundwork for Musk’s subsequent deal. Dorsey warned that Twitter’s advertising business was susceptible to government and advertiser pressure. He also shared his own views that Twitter would be better served as a private company, where it wouldn’t be constantly battered by Wall Street investors demanding more growth. When Twitter and Musk initially announced the $44 billion agreement, in April of 2022, Dorsey sent Musk a private message within minutes.

“Thank you,” he wrote, including a heart emoji.

“I basically following [sic] your advice!,” Musk wrote back.

“I know and I appreciate you,” Dorsey replied. “This is the right and only path. I’ll continue to do whatever it takes to make it work.”

Dorsey even rolled over about $1 billion of his Twitter stock into Musk’s new venture, and quickly set Musk up on a call with Twitter’s C.E.O., Parag Agrawal, in hopes the two would start collaborating. (The call ended up being a disaster.)

You probably know the rest of the story by now: Musk tried to get out of the deal, Twitter sued him, a lengthy legal dispute followed, and Musk is now the proud if not reluctant owner of X, the remnants of what Twitter used to be.

As I wrote my book about this saga, though, I couldn’t stop coming back to this Dorsey-Musk relationship. Musk had many reasons for buying Twitter beyond Dorsey’s encouragement, and Dorsey was just one vote on a board that voted unanimously to approve the deal. Yet it still feels like the connection between these two men sits at the heart of Twitter’s story.

Dorsey, as his former colleagues will tell you, was oftentimes infatuated with celebrities who had reached the height of their craft. He greatly admired Kanye West, now known as Ye, for example, and similarly tried to land him a speaking spot at one of Twitter’s companywide retreats. (That Ye had recently suggested slavery was a “choice” did not seem to deter Dorsey.)

The Twitter C.E.O. felt similarly passionate about Jay-Z, and he used his other company, Block (the financial-services platform formerly called Square), to acquire the rapper’s struggling music-streaming service, Tidal, for about $300 million in 2021. Jay-Z also got a seat on Block’s board. (Some shareholders later sued the company over the deal, suggesting that Dorsey was simply bailing out his friend’s business. A Delaware court judge dismissed the suit, but also concluded the deal looked like “a terrible business decision.”)

In the world of tech, there is perhaps no bigger celebrity than Musk, and Dorsey’s admiration remained steadfast long after it became clear that his deal to buy Twitter was headed for disaster. It’s a devotion that’s had consequences. Many of Dorsey’s old Twitter employees, who were once avid supporters, have since turned against him. They struggled to comprehend why their old boss was content to sit by and watch the new boss turn the company inside out.

A month before Musk abandoned the Twitter name and rebranded the company as X, Dorsey was still holding out hope. “I do have confidence that he’ll figure it out,” Dorsey said about Musk on the online political show Breaking Points this past June.

Musk, after all, was Dorsey’s favorite tweeter.

Kurt Wagner is a journalist for Bloomberg