In addition to buying $5 billion in preferred stock, Berkshire also got warrants to buy another $5 billion in Goldman's common stock. Goldman also said late Tuesday it would raise another $2.5 billion in its own public stock offering.
The news sent shares of Goldman Sachs and stock index futures soaring in electronic trading, after the Dow Jones Industrial Average posted a triple-digit decline for the second day in a row.
It also could lead to new probing questions from lawmakers for Treasury Secretary Hank Paulson, a former co-CEO of Goldman Sachs. He and Federal Reserve Chairman Ben Bernankethat quick action on a $700 billion bailout measure for financial services firms was needed to prevent economic havoc.
The legislation that the administration is seeking would allow the government to buy bad mortgages and other troubled assets held by endangered banks and financial institutions.
Getting those debts off their books should bolster the institutions' balance sheets, making them more inclined to lend and easing one of the biggest choke points in the credit crisis. If the plan works, it could help lift a major weight off the sputtering national economy.
The government has to be careful. They can't pay too much for this distressed debt or taxpayers will have a tough time getting their money back. But they can't pay too little or the banks won't get the financial help they need to survive, reports CBS News correspondent Anthony Mason.
Goldman Sachs' shares had been tumbling ahead of the announcement of the government rescue plan last Friday as investors feared it could face the same kinds of funding squeezes as Bear Stearns and Lehman. Now members of Congress have to deal with a plan while it looks to many taxpayers like Wall Street is already cashing in.
Buffett, one of the most successful investors in history, made no mention of what is happening in Washington, but he did heap praise on the New York-based company.
"Goldman Sachs is an exceptional institution," the chairman and CEO of Berkshire Hathaway said in a news release. "It has an unrivaled global franchise, a proven and deep management team and the intellectual and financial capital to continue its track record of outperformance."
Buffett's investment comes two days after Goldman Sachs Group Inc. and Morgan Stanley, the last two independent investment banks on Wall Street, won approval from the Federal Reserve to change their status to bank holding companies.
By becoming commercial banks, the two companies avoided the fate of Bear Stearns and Lehman Brothers - the first taken over in a fire sale and the second now bankrupt - by giving them broader access to borrow federal money and the ability to build a stable base of deposits.
But it also comes with closer regulatory oversight that likely limit its ability to generate the kinds of sky high profits that were topped by few others companies.
The strict rules set by the Federal Reserve will limit opportunities for big payoffs from what is known as proprietary trading, using borrowed funds to place high-octane bets on everything from the price of oil to currencies and other commodities.
Berkshire's preferred stock in Goldman will pay 10 percent and can be bought back any time at 10 percent premium. The warrants allow Berkshire to buy $5 billion in common stock at $115 per share any time over the next five years.
Goldman's shares rose $4.27, or 3.5 percent, to close at $125.05 Tuesday in the regular trading session, and jumped another $8.46, or 6.8 percent, to $133.20 in after-hours trading following the announcement of Buffett's investment.
Morgan Stanley's shares rose 91 cents, or 3.4 percent, to $28 in the regular session, then soared $3, or 10.7 percent, to $31 in after-hours trading.
Morgan Stanley got its own cash infusion on Monday, agreeing to sell a 20 percent stake for more than $8 billion to Mitsubishi UFJ Financial Group Inc., Japan's largest bank.
Mark Lane, an analyst who follows Goldman for William Blair & Co. in Chicago, said he had expected Goldman and Morgan Stanley to raise capital after getting the Fed's approval to become bank holding companies.
Buffett's investment "sends a pretty strong message of support for the independent-bank business model," Lane said. "It sends a stabilizing signal to the market."
On Sept. 14, the No. 4 investment bank, Lehman Brothers, filed for the largest bankruptcy in U.S. history, weighed down by fouled commercial real estate holdings and a loss of faith from investors, and on the same day ailing Merrill Lynch & Co. arranged a hasty deal to be bought by Bank of America Corp.
Wall Street's troubles came as a freeze-up in credit markets threatened to clog the global financial system. The U.S. government arranged an $85 billion loan last week to rescue the huge insurer American International Group Inc. and is seeking approval from Congress to buy back some $700 billion in bad mortgages and other toxic debts from financial institutions.
A message left for a Berkshire spokeswoman seeking further comment on the transaction wasn't immediately returned Tuesday. Berkshire officials do not typically comment on its stock investments beyond what they are legally required to disclose.
A spokeswoman at Goldman Sachs said no one was immediately available to talk about the deal.
At last report, Berkshire had total assets of nearly $278 billion, including significant stakes in companies such as Wells Fargo & Co., American Express and the Washington Post Co.