U.S. stocks surged on Friday as President Bush and Federal Reserve Chairman Ben Bernanke reassured investors they would do what was needed to shelter the economy from market turmoil.

Banks and brokers, which have borne the brunt of the recent credit crisis, rose in thin trading before a long holiday weekend. Citigroup's shares climbed 1.4 percent.

Bernanke said the Fed would not bail out investors who had made mistakes, but overall his comments reinforced the view that the Fed will cut interest rates at its meeting on Sept. 18.

Shares of Fannie Mae and Freddie Mac, the two large U.S. housing finance companies, rose as investors speculated they may benefit from a Bush plan to help homeowners struggling to meet mortgage payments.

This is a nice one-two punch, said Jim Paulsen, chief investment officer at Wells Capital Management in Minneapolis.

You've got the Fed sticking to their guns and ensuring they are building confidence by remaining calm and at the same time the federal government is coming in with a safety net. This helps people look at this as maybe the beginning of the end of the crisis.

The Dow Jones industrial average was up 119.01 points, or 0.90 percent, at 13,357.74. The Standard & Poor's 500 Index was up 16.35 points, or 1.12 percent, at 1,473.99. The Nasdaq Composite Index was up 31.06 points, or 1.21 percent, at 2,596.36.

While the S&P and Dow fell for the week, all three indexes posted their first monthly gains since May. The Dow rose 1.1 percent, the S&P climbed 1.3 percent, while the Nasdaq surged 2 percent in August.

Rising default rates on home loans to less credit-worthy U.S. borrowers, coupled with falling house prices, have triggered sharp losses for banks and funds holding mortgage-linked securities in recent months and fostered the worst global credit and liquidity squeeze in a decade.

Bush urged lenders to work with homeowners to renegotiate loan terms and called on Congress to approve legislation to modernize the Federal Housing Administration, which provides mortgage insurance to borrowers through private sector lenders.

But the president also said it was not the government's job to bail out speculators, a remark that briefly caused stocks to pare gains.

Fannie Mae's shares rose 3.5 percent to $65.61, while Freddie Mac gained 2.6 percent to $61.61 on renewed hopes they will have a bigger role helping borrowers.

Economic data took a back seat to the market's attention on the remarks by Bush and Bernanke.

Reports on Friday showed inflation under control in July while U.S. factories were busier than forecast, portraying an expanding economy. But other data showed U.S. consumer sentiment worsened in August from July, while the outlook for economic growth weakened.

Technology shares again posted strong gains. Apple Inc led the tech-heavy Nasdaq higher on optimism about the expected launch of new iPods. Apple gained 1.6 percent to $138.48.

Financial shares, which have borne the brunt of worries about deteriorating credit conditions, rose. JPMorgan Chase was up 1.3 percent at $44.52, while Citigroup climbed to $46.88.

Trading was thin on the NYSE with many traders and investors already on the road ahead of a long holiday weekend. Markets in the United States will be closed on Monday for Labor Day.

About 1.39 billion shares changed hands, far short of last year's estimated daily average of 1.84 billion, while on Nasdaq about 1.55 billion shares traded, also well below last year's daily average of 2.02 billion.

Rising stocks outnumbered falling ones by a ratio of about 6 to 1 on the NYSE and by 2 to 1 on Nasdaq.