Elon Musk's pursuit of Twitter was a melodrama from the beginning -- a mercurial billionaire locked in a bitter fight with his favorite social media platform.
After months of recriminations and attempts to cancel his attempt to buy, Musk on Tuesday called a truce and agreed to honor his initial offer.
Here are the main ups and downs of the saga:
Musk is a long-time Twitter user with more than 100 million followers, using the platform as a megaphone for his corporate and personal ambitions.
In an April 4 regulatory filing, he revealed he had splashed out nearly $2.9 billion on a 9.2 percent stake in the company.
PAY ATTENTION: Subscribe to Digital Talk newsletter to receive must-know business stories and succeed BIG!
Elon Musk bows, to Proceed with Twitter deal as billionaire annoys Ukrainians over Twitter poll on war
Twitter shares soared, Musk got a seat on the board, and CEO Parag Agrawal called him "a passionate believer and intense critic of the service", saying it was "exactly what we need".
Both sides appeared to be getting along famously.
But it took less than a week for things to fall apart.
Musk decided against joining the board, and Agrawal said it was "for the best".
Musk then launched a hostile takeover bid, an April 13 filing showed, and Twitter adopted a "poison pill" defense that would allow shareholders to buy additional stock.
Deal back on
Then Twitter reversed course and on April 25 revealed that it would sell after all in a deal that valued the firm at $44 billion.
Musk parted with $8.4 billion in shares in Tesla, pledged up to $21 billion from his personal fortune and got some friends to stake him a few billion.
The billionaire mogul, known for his provocative messages, set out plans to allow former US president Donald Trump back on to the platform.
See you in court
Then it was Musk's turn to get cold feet. He said on May 13 the deal was "temporarily on hold" while he sought details of spam and fake accounts on the platform.
After two months of very public fighting over the issue, he called off the deal and accused Twitter of making "misleading" statements.
The company quickly launched legal action to enforce the deal.
Both sides had been gearing up for a lengthy and hugely expensive showdown at the Delaware Chancery Court.
Musk had been buoyed by whistleblower revelations that portrayed the company as cavalier with its bot counting and lax on security.
Twitter, however, believed the agreement it had with Musk was watertight.
Then, on Tuesday, Musk revealed -- on Twitter, of course -- that he had agreed to close the deal at the price he had initially offered.
"I think that Musk realized he was not going to win that trial," said law professor Carl Tobias.
The future is 'X'
In his tweet on Tuesday, Musk said the acquisition would be an "accelerant" towards creating "X", which he said would be "the everything app".
He offered no further detail.
He had previously told Twitter staff that he envisaged a platform with one billion users, but he was hazy on issues like potential staff layoffs and free-speech limits.
Text messages revealed during the legal process showed how he briefly considered making a blockchain-based social media app.
But before the future of Twitter can even be discussed, either side could still quibble over the details of the sale.
The potential of a courtroom showdown has receded but remains a possibility.