The richest man in the world, Musk, struck a deal on Monday to buy the social network for roughly $44 billion.

The company agreed to be sold to Mr. Musk for a 38 percent premium over its share price before he revealed he was the firm's largest shareholder. It would be the biggest deal to take a company private.

Mr. Musk said in a statement that free speech is the bedrock of a functioning democracy and that the digital town square is where matters vital to the future of humanity are debated.

The deal caps what seemed to be an unlikely attempt by Mr. Musk to buy a platform that is used by millions of people around the world.

The billionaire, who has more than 83 million followers on the service, has repeatedly said he wants to transform the platform by promoting more free speech and giving users more control. Taking the company private would allow Mr. Musk to work on the service out of the public eye.

It is likely that scrutiny will be intense. It is not the biggest social platform, with more than 217 million daily users, but it has an outsize role in shaping narratives around the world. Companies, celebrities and others have used it to hone images and build brands, while political leaders have made it a megaphone.

Some users have spread misinformation and other toxic content on the service, which has become a target of criticism. After the January 6 riot at the Capitol, Donald J. Trump stopped using the social media platform to insult and inflame. The company creates policies on the fly to deal with unforeseen situations.

Mr. Musk had a rocky relationship with online speech. He tried to quash the account that tracked his private jet because of personal and safety reasons. He got into trouble with regulators over his social media activity.

He said on Monday that he hoped his worst critics would stay on the platform.

Mr. Musk may not be in favor of community standards for online speech, which could be problematic for the deal.

She said that this is a slippery slope.

Republicans in Washington cheered Mr. Musk's deal.

I am hopeful that Musk will help rein in Big Tech's history of censoring users that have a different viewpoint.

Mr. Trump told Fox News that he would keep posting on his own social network, Truth Social.

Democrats were not allowed to speak on the deal. President Biden has long been concerned about the power of large social media platforms, and that they should be, according to the White House press secretary.

Beyond speech issues, there are questions about its business. The company has struggled to gain new users. The main way that it makes revenue is through advertising. For the last 10 years, the company has not turned a profit.

The company lost half a billion dollars last year. Meta, the company formerly known as Facebook, had profits of $39 billion and revenue of $118 billion last year.

The company has had a tumultuous history. It has dealt with drama with its founders and has been courted by other interested buyers in the past. In 2020, the activist investment firm called for the resignation of Jack Dorsey, one of the founding fathers of the company. Mr. Dorsey stepped down last year.

According to a professor at the University of Pennsylvania Wharton School of Business, this company is undermonetized compared to other platforms and competitors.

The board conducted a thoughtful and comprehensive process on Mr. Musk's bid, according to a statement from the chairman.

Former antitrust officials said that regulators are unlikely to challenge the transaction since the government usually intervenes to stop a deal.

The deal was done in a few weeks. Mr. Musk disclosed this month that he had amassed a stake of more than 9 percent in the micro-blogging site.

There was a guessing game over what Mr. Musk would do with the platform. He was initially welcomed to the board of directors by the executives, but then reversed course and began a bid to buy the company.

The entrepreneur did not say how he would finance the deal. It was difficult to discern how much Mr. Musk might be joking. He wrongly claimed that he had secured funding for a private deal when he said he planned to take the company private.

Thepoison pill was put in place to prevent Mr. Musk from accumulating more than 15% of the company's shares.

The skepticism dissipated last week when Mr. Musk revealed in a securities filing that he had obtained commitments worth $46.5 billion.

Morgan Stanley and a group of other banks offered over $13 billion in debt financing and loans against Mr. Musk's stock in the company. He was expected to add $21 billion in equity financing. The equity financing was not provided on Monday. There were no conditions for Mr. Musk's financing that would prevent him from closing the deal.

People with knowledge of the situation said that the financing commitments forced the company to weigh Mr. Musk's bid seriously, particularly as he threatened to take the offer directly to shareholders in a hostile bid.

Over the weekend, in a series of calls and video meetings, the board and the billionaire havehed out terms for the purchase. The teams worked late Sunday and into Monday.

Morgan Stanley was the lead financial adviser to Mr. Musk.

It's not clear how hands-on Mr. Musk will be. He might pick someone to lead the company and how involved he would be in running the service are some of the unanswered issues. Mr. Musk has other companies, such as Neuralink, which aims to build a computer interface for the human brain, and the Boring Company, which makes tunnels.

Parag Agrawal took over in November. Mr. Agrawal is trying to decentralize the social network so that users have more control over their social feeds. He is expected to remain in charge until the deal closes.

How many of the employees want to work for Mr. Musk is uncertain. The lack of communication over the takeover fight has frustrated some.

In a meeting with employees on Monday, Mr. Agrawal and Mr. Taylor nodded to the emotions of the day and how workers were most likely processing the news of a sale

Mr. Agrawal told The New York Times that it was important to acknowledge that everyone had different feelings about what was happening. He said it might take three to six months for the deal to be completed.

The deal is expected to close this year, subject to shareholder and regulatory approvals.

Mr. Agrawal acknowledged the uncertainty in the employee meeting.

Kate Conger, Cecilia Kang and David McCabe were involved in the reporting.