Warren Buffett, one of the richest men in the world, is to invest up to $10bn (£5.4bn) in Goldman Sachs as the investment bank attempts to bolster its financial position amid continued fallout on Wall Street as a result of the sustained credit crisis.

Mr Buffett, known as the "Sage of Omaha" for his legendary investment skills, will buy an initial $5bn holding through his Berkshire Hathaway investment vehicle, and will receive warrants to buy up to another $5bn at a later date.

Goldman is also raising a further $2.5bn through a public offering of its shares, which soared by 8.4pc to $135.56 in extended after-hours trading.

The investment is a major vote of confidence in the bank, which has largely avoided the worst of the sub-prime crisis, but also highlights just how precarious the market has become that an institution such as Goldman feels the need to raise money in the first place.

The news – perhaps unthinkable just a fortnight ago – should act as a fillip for the wider stock market, given that Mr Buffett is perceived by many as a shrewd investor to whom timing is crucial. Dow Jones index futures were last night trading 160 points higher, following a 161 point fall in normal trading hours yesterday.

It is the first time Mr Buffett has bought a stake in an investment bank since purchasing a holding in Salomon Brothers in 1987.

His investment comes just a day after Goldman changed its legal status to allow it to become a federal holding bank. "Buffett did this after Goldman converted to a bank holding company," said Pat Dorsey, director of equity research at Morningstar, meaning that the US Federal Reserve is now Goldman's regulator.

"Buffett is saying that, with less leverage and more stable sources of funding, this is an institution worth investing in. From Buffett's perspective you have a world-class firm in a less-competitive landscape, with a hopefully less-risky business model."

As a result of its initial investment, Berkshire will own the equivalent of a 10pc stake in Goldman, based on last night's closing market capitalisation, in return for buying $5bn of perpetual preferred shares which will pay a 10pc dividend and which the bank can buy back at any time for a 10pc premium.

Berkshire will also receive warrants to purchase $5bn of ordinary shares at a strike price of $115 a share at any point over the next five years.

Mr Buffett said last night "Goldman Sachs is an exceptional institution" with "the intellectual and financial capital to continue its track record of out-performance".

Although the fact that it is Mr Buffett who has chosen to invest in the company will come as a surprise to many, the market has been awash with rumours for days that Goldman was on the verge of some form of fundraising.

Just last week, UBS analyst Glenn Schorr, following a meeting with Goldman chief financial officer David Viniar, wrote that he was "pretty confident" that the bank's management was "lining up all viable options".