Warren E. Buffett, the country’s most famous investor and one of the world’s richest men, announced on Tuesday that he would invest $5 billion in Goldman Sachs, the embattled Wall Street titan, in a move that could bolster confidence in the financial markets.

Until now, Mr. Buffett, who has navigated the stock market with legendary prowess, has largely refrained from investing in the stricken financial industry, saying repeatedly that things could get worse.

Thousands of people on and off Wall Street follow Mr. Buffett’s moves, so his decision to invest in Goldman immediately heartened investors.

“Buffett is saying he’s confident,” said Brad Hintz, an analyst at Sanford C. Bernstein & Company.

Mr. Buffett’s conglomerate, Berkshire Hathaway, unveiled the move only days after Goldman, long the premier investment house on Wall Street, embarked on a radical plan to transform itself into a traditional bank to ensure its survival. Goldman, which examined various options over the last week as its shares tumbled and some clients abandoned the firm, also said Tuesday it would sell at least $2.5 billion of common stock to the public.