NEW YORK (CNNMoney) -- U.S. stocks fell from earlier highs but still managed to snap a three-session losing streak Wednesday after Federal Reserve chairman Ben Bernanke reiterated that the central bank remains ready to provide additional stimulus.
The S&P 500 () added 4 points, or 0.3%, and the Nasdaq composite ( ) gained 15 points, or 0.5%.
It was a good day for stocks. Earlier in the session, all three indexes had climbed more than 1%.
The day started on an upbeat note as investors cheered China's healthy economic growth.
China's economy grew at an annual pace of 9.5% between April and June, the National Bureau of Statistics said Wednesday. That marks a slight slowdown from the first quarter, but was higher than economists expected.
"That serves as positive reinforcement for the global economy," said Ryan Detrick, senior technical strategist at Schaeffer's Investment Research.
But the big driver behind Wednesday's gains was Bernanke.
After months of adamantly denying another round of stimulus, the Fed chief opened the door a crack during his semi-annual address to Congress.
Bernanke told lawmakers that the central bank is "prepared to respond should economic developments indicate that an adjustment in the stance of monetary policy would be appropriate."
The possibility of additional stimulus offered some relief for investors who have been worried that the recent soft economic data could stall the recovery.
"Bernanke came out and said that the Fed has the tools to support economic growth, and is ready to use them," said Timothy Ghriskey, chief investment officer at Solaris Asset Management. "That's giving investors confidence."
However, Detrick said that trading will remain volatile as investors continue to face headwinds from Europe's sovereign debt crisis.
Wednesday afternoon, Fitch Ratings cut Greece's credit by three notches to CCC, sending the debt-ridden country's rating further into junk territory. The market had a muted reaction but the news served as yet another reminder of Europe's ongoing debt troubles.
"Europe's fiscal crisis is on the back burner for today, but there are still a lot of negative forces out there," Detrick said.
Oil for August delivery rose 62 cents to settle at $98.05 a barrel.
Gold futures for August delivery rose $23.20 to settle at a record $1,1585.50 an ounce. Earlier Wednesday, the precious metal hit an intraday record of $1,588.90 an ounce.
Bonds: The price on the benchmark 10-year U.S. Treasury rose slightly, with the yield edging lower to 2.88% from 2.91% Tuesday.
Companies: News Corp. ( , Fortune 500) was a big winner on both the S&P 500 and the Nasdaq. Shares spiked nearly 4% after the company withdrew its bid for satellite TV company British Sky Broadcasting. The media giant said it plans to remain a long-term shareholder of BSkyB.
Late Tuesday, Electronic Arts (PopCap Games for $750 million in cash and stock. Shares of the company fell 1.1% Wednesday.) announced it is buying mobile game maker
World markets: European stocks finished higher. Britain's FTSE 100 gained 0.6%, the DAX in Germany added 1.3%and France's CAC 40 rose 0.5%.
|What we want Apple to unveil at WWDC|
|Millennials squeezed out of buying a home|
|7 traits the rich have in common|
|Big Data knows you're sick, tired and depressed|
|Your car is a giant computer - and it can be hacked|
|Overnight Avg Rate||Latest||Change||Last Week|
|30 yr fixed||3.60%||3.68%|
|15 yr fixed||2.73%||2.79%|
|30 yr refi||3.64%||3.72%|
|15 yr refi||2.77%||2.82%|
Today's featured rates: