Harmony Gold, the world's sixth-biggest producer of the precious metal, has failed in its hostile takeover of larger rival Gold Fields.
The bid by Harmony has seen Gold Fields' share price drop by half
A South African court ruled that the bid expired five months ago and an extension of the offer was not valid.
The extended offer was due to expire at 1000GMT on Friday.
The ruling means that Harmony only managed to acquire 11.5% of Gold Fields after months of bitter fighting and costs of over $50m (£27m; 40m euros).
"All of the money these guys have spent since December, that's money down the drain," said Stephen Roelofse of Sanlam Investment Management.
The High Court in South Africa ruled that the country's Security Regulation Panel (SRP) was not right to let Harmony extend its offer beyond the normal 60-day takeover limit, which started on 18 October, 2004.
As a result, any shares bought after 18 December had to be returned to investors.
Harmony chief executive Bernard Swanepoel said he was surprised by the High Court decision but that the company now has "a substantial asset in Gold Fields shares".
Mr Swanepoel estimates that the holding in Gold Fields is worth about 3.6bn rand ($54m; £30m).
Harmony denied reports that it planned to sell the stake, adding that it wanted to conclude a "strategic" deal with another party.
That could cover a wide range of agreements, including a swap of shares for mining operations, the company said.
For its part, Gold Fields said it was relieved the hostile takeover had failed, freeing it up to forge closer links with its key Russian shareholder Norilsk Nickel.
"It's a pity that this thing had to go on for five months longer than was necessary," said Gold Fields' chief executive Ian Cockerill. "I'm relieved that it's over."