Elon Musk has bought influential social media company Twitter for $61.5 billion (US$44 billion) after a month-long siege that saw Twitter on the brink of diluting its shares to keep Musk away.

Current Twitter shareholders will be paid $75.80 (US$54.20) per share in an agreement that Musk has framed as a win for free speech.

“Free speech is the bedrock of a functioning democracy, and Twitter is the digital town square where matters vital to the future of humanity are debated,” he said in a statement.

“I also want to make Twitter better than ever by enhancing the product with new features, making the algorithms open source to increase trust, defeating the spam bots, and authenticating all humans.”

Musk has been spouting his vision for Twitter since the start of this month when it became public that he had become Twitter’s largest shareholder after buying 9.2 per cent of the company’s stock for $3.8 billion (US$2.8 billion).

In response to the large share purchase, Twitter’s management offered Musk an olive branch in the form of a board seat.

This would have let Twitter have its cake and eat it too by appeasing one of the platform’s biggest personalities and giving him input into the company’s direction.

But the terms of that arrangement would have limited Musk’s ability to increase his stake to 15 per cent and he quickly performed an about-face, turning down the offer just days after signalling his desire to work with Twitter.

Twitter management prepared its defense in the form of a ‘poison pill’ that would have created more shares in order to dilute Musk’s takeover attempt, while Musk’s bankers began calling around to find loans that would fund the extraordinary takeover bid.

By the end of last week, Twitter was staring at a fully-financed offer after Musk managed to borrow around $35.6 billion (US$25.5 billion) and is putting up $29.3 billion (US$21 billion) in equity to make the purchase.

Bret Taylor, chair of the Twitter board, said the board had “conducted a thoughtful and comprehensive process” when looking over the offer.

“The proposed transaction will deliver a substantial cash premium, and we believe it is the best path forward for Twitter's stockholders,” he said in a statement.

Twitter CEO Parag Agrawal’s statement was muted, saying the company “has a purpose and relevance that impacts the entire world”.

“Deeply proud of our teams and inspired by the work that has never been more important.”

As the deal was being finalised, Musk continued his habit of sharing thoughts on the short-form micro-blogging platform.

“I hope that even my worst critics remain on Twitter, because that is what free speech means,” he tweeted just prior to the deal being finalised.

Over the weekend Musk caused a stir with a childish tweet poking fun at Microsoft founder Bill Gates’ likeness after discovering Gates holds a short position on Tesla’s share price.