The U.S. economy needs help because unemployment is high, Bernanke said. His remarks seemed to ease investors' fears that the central bank would pull back on its economic stimulus too quickly. The Fed is buying $85 billion a month in bonds to keep interest rates low and encourage spending and hiring.
The yield on the 10-year Treasury note continued to decline as investors bought bonds. The yield on the 10-year note fell to 2.57 percent from 2.63 percent Wednesday. The yield was as high as 2.74 percent Friday after the government reported strong hiring in June. Stocks that benefit most from a continuation of low interest rates, such as homebuilders, notched some of the biggest gains. D.R. Horton rose $1.93, or 9.2 percent, to $22.98 and Lennar Group climbed $2.88, or 8.3 percent, to $37.44.
The S&P 500 index jumped 22.40 points, or, 1.4 percent, to 1,675.02, surpassing its previous record close of 1,669 from May 21. The index rose for a sixth straight day, its longest streak in four months.
The Dow rose 169.26 points, or 1.1 percent, to 15,460.92, above its own all-time closing high of 15,409 set May 28.
The Nasdaq composite rose 57.54 points, or 1.6 percent, to 3,578.30.
Gold gained for a fourth straight day, climbing $32.50, or 2.6 percent, to $1,279.90 an ounce. Gold is rising because the prospect of continued stimulus from the Fed could weaken the dollar and increase the risk of inflation.
In other economic news:
For June, U.S. retailers reported their strongest sales gains since January, as shoppers, enticed by warm weather and an improving economy, took advantage of summer discounts.
Revenue at stores opened at least a year - an industry measure of a retailer's health - rose 3.9 percent in June compared with the same month a year ago, according to a preliminary tally of 12 retailers by the International Council of Shopping Centers. The mall trade group had expected an increase of 3 percent to 3.5 percent.
The federal government reported a rare surplus of $116.5 billion for June, the largest for a single month in five years. The gain kept the nation on track for its lowest annual deficit in five years.
The June surplus was due in part to $66.3 billion in dividend payments from Fannie Mae and Freddie Mac. The mortgage giants were taken over by the government at the height of the 2008 financial crisis and are now repaying taxpayers for the support they received.
Foreclosure listing firm RealtyTrac says that the number of U.S. homes repossessed by lenders fell nearly 9 percent in June from the previous month. Repossessions declined 35 percent from a year earlier. The number of homes that entered the foreclosure process last month tumbled 21 percent last month from May, and slid 45 percent from June 2012.
Through the first six months of 2013, Florida's foreclosure rate was the highest in the nation and nearly three times the national average.
The number of people applying for U.S. unemployment benefits rose 16,000 last week to a seasonally adjusted 360,000, although the level remains consistent with steady hiring. The Labor Department said the less volatile four-week average increased 6,000 to 351,750.
The weekly applications data can be volatile in July because some automakers briefly shut down their factories to prepare for new models and many schools close. Those factors can create a temporary spike in layoffs. The broader trend has been favorable.