"Bernanke is coming around to where the rest of America is" when it comes to the U.S. economy, said Paul Nolte, director of investments at Hinsdale Associates.
After an early fall, the Dow Jones Industrial Average gained 12.13 points to 12,666.49, with 17 of its 30 components trading higher.
Financials, which led Tuesday's rally, continued to show some strength among the blue chips, with Citigroup Inc. up 3.2%.
The S&P 500 climbed 5.02 points to 1,375.20.
On the S&P, consumer discretionary stocks rose the most, up 1.9%, followed by financials, ahead 1.5%, and information technology, which gained 1.2%.
Only the health-care and consumer staple sectors lagged, with the latter off 0.5% and health-care stocks down just 0.1%.
The Nasdaq Composite gained 13.84 points to 2,376.59.
While the broader market lapsed, retail shares got a boost from Best Buy's better-than-expected outlook and fourth-quarter results, with shares of the nation's largest electronics retailer up 1.8%. .
Shares of other retailers gained as well. .
"We're still up on the day, based on hopes that nonfarm payrolls will be better than expected. But it's hard to hold onto that after the big rally we had yesterday," said Art Hogan, chief market strategist at Jefferies & Co.
Volume on the New York Stock Exchange neared 1.9 billion, while 909 million shares were exchanged on the Nasdaq. Advancers led decliners on both exchanges, by 2 to 1 on the NYSE and 3 to 2 on the Nasdaq.
Beginning two days of testimony, Bernanke said he could not rule out a possible recession, although the Fed chief did not back off his view that the economy would pick up in the second half of the year. .
"The bottom line is the Fed has downgraded the near-term economic outlook since its latest round of projections," said Stephen Stanley, chief economist at RBS Greenwich Capital.
"The market's hesitations are also a reflection of what's going on with Bernanke's testimony. Those congressmen represent their constituents, people who have had trouble keeping their homes, and they're facing a man that has just rescued Bear Stearns; even if it was to save the financial system, it reeks of a Wall Street bail-out," said Hogan.
Ahead of the opening, stock index futures added to earlier gains after an ADP report found the private sector added 8,000 jobs in March, with the data coming two days before Friday's pivotal employment report. .
In early activity on the New York Mercantile Exchange, gold edged up after two sessions of sharp losses; gold for June delivery climbed $8.1 to $891 an ounce. .
Elsewhere on the NYME, crude-oil futures gained, with the contract for May delivery up 2 cents at $101 a barrel, following Tuesday's 60-cent drop to $100.98 a barrel. .
Overseas, European shares extended second-quarter gains as banks such as UBS AG advanced. .
By Kate Gibson