Homebuilders got a lift from a report Thursday suggesting that the housing recovery remains intact. The number of people who signed contracts in May to buy a home jumped to the highest level in more than six years. D.R. Horton rose 79 cents, or 3.8 percent, to $21.71. Lennar gained $1.37 cents, or 3.8 percent, to $37.38.
Investors were also encouraged by comments from key Fed officials. The president of the New York branch of the Federal Reserve said the central bank would likely keep buying bonds if the economy failed to grow at the pace the Fed was expecting.
"If labor market conditions and the economy's growth momentum were to be less favorable than in the (Fed's) outlook — and this is what has happened in recent years — I would expect that the asset purchases would continue at a higher pace for longer," William Dudley said at a news conference in New York.
That message was reinforced by two other Fed officials Thursday. Jerome Powell, a member of the Fed's board in Washington, said investors appear to have incorrectly concluded that the Fed will taper its purchases soon. Dennis Lockhart, president of the Fed's Atlanta branch, said that the pace of purchases still depended on "how economic conditions evolve."
While the S&P 500 index is on track to record its first monthly loss since October, the index is still poised to end June with the best first half of a year since 1998, when it rose 17.7 percent. The index has gained 13.2 percent so far this year.
The market will likely remain volatile though the second half of the year as investors assess when the Fed will end its stimulus, said Kate Warne, investment strategist at retail brokerage firm Edward Jones.
"The general outlook for the economy is solid," Warne said. "The trend in stock prices is likely to continue to be higher, even though we'll see a lot more zig-zagging as everyone debates the timing of the Fed's next move."
The price of gold fell $18.20, or 1.5 percent, to $1,211.60 an ounce, following a 3.6 percent slump Wednesday. It traded below $1,200 for the first time since August 2010. Gold has dropped 28 percent this year as Treasury yields have risen and the dollar has strengthened, diminishing gold's appeal as an alternative investment.
Crude oil rose $1.55, or 1.6 percent, to $97.05 a barrel. The dollar fell against the euro and the Japanese yen.
Among stocks making big moves:
— ConAgra Foods rose $1.69, or 5.1 percent, to $35.04 after the company posted a quarterly profit that came in a penny above the forecasts of Wall Street analysts. The maker of Chef Boyardee, Hebrew National and other packaged foods benefited from acquisitions and price cuts that helped increase sales. —Payroll processor Paychex fell $1.39, or 3.7 percent, to $36.60 after posting earnings that fell short of analysts' expectations. The company said profit for the three months through May 31 came in roughly flat at 34 cents per share. Analysts had expected earnings of 37 cents a share.