Tech billionaire Elon Musk now wants to take over the online service Twitter after all. Some investors have bet for the past few months that the Tesla boss won’t go through with a lawsuit he’s likely to lose — and are now reaping hefty profits.

After months of bickering, Elon Musk’s takeover of Twitter could finally happen. The fact that the Tesla boss gave in shortly before the eagerly awaited court case and renewed his offer is also a big win for some well-known investors.

Investor Carl Icahn, for example, has quietly built up a stake in Twitter worth over $500 million over the past few months, according to people familiar with the matter. After Twitter shares soared as a result of Musk’s willingness to make the transaction on the original terms, Icahn also made a sizeable profit.

Twitter shares rose 22 percent yesterday to $52. Icahn paid about $30 a share for his stake, according to informants. That means the estimated earnings for his Icahn Enterprises LP could top $250 million.

Other major investors such as D.E. Shaw Group and Daniel Loeb’s Third Point LLC have also been betting on Twitter stocks for the past few months and could make significant gains of their own, according to others familiar with the matter.

Icahn made the investment on the assumption that Tesla CEO Musk would not go through with a lawsuit that he was likely to lose, according to some of the people. Icahn also thought the stock would only be worth around $35 long-term anyway, so losses would be limited — even if Musk were to win the case.

With a looming court hearing to resolve the dispute with Twitter, Musk surprisingly offered to complete the acquisition of Twitter on the original terms he agreed to earlier this year. It’s an abrupt and surprising reversal after Musk waged a months-long campaign to get out of business.