Encouraging news about the U.S. jobs market trumped higher oil prices and worrying developments in Europe's debt crisis on Wednesday.
Oil climbed above $102 a barrel for the first time in more than a year as the political turmoil in Egypt intensified, raising the risk of supply disruptions in the Suez Canal. In Europe, traders dumped Portuguese stocks and bonds as the country's government teetered on the edge of collapse.
That news was offset though by a brighter outlook on U.S. jobs ahead of Friday's monthly employment report. The stock market opened lower, then drifted higher in late morning trading. By noon, indexes turned positive.
"The key takeaway is that jobs matter more than Egypt," said Alec Young, a global equity strategist at S&P Capital IQ. "Nothing is more important to the state of the economy than the jobs market."
In the U.S., fewer people sought unemployment benefits last week and ADP, a payrolls processor, said businesses added more jobs last month than analysts had expected. The government's broader monthly survey of U.S. employment is scheduled to be released Friday morning. Economists predict that employers added 165,000 jobs in June.
The Dow Jones industrial average closed up 56.14 points, or 0.4 percent, to close at 14,988.55.
The Standard & Poor's 500 rose 1.33 points, or 0.1 percent, to 1,615.41. The Nasdaq composite gained 10.27 points, or 0.3 percent, to 3,443.67.
Trading closed at 1 p.m. Eastern Daylight Time ahead of the July 4th holiday Thursday. Regular trading will resume Friday.
Investors will be watching the government's jobs report closely in hopes of figuring out what the Federal Reserve will do next.
Fed chairman Ben Bernanke said June 19 that the central bank was considering easing back on its stimulus program later this year if the economy strengthens enough. The central bank is buying $85 billion in bonds every month to keep interest rates low and encourage spending.
The Fed may be forced to keep stimulating the economy because U.S. growth remains muted, said Derek Gabrielsen, a wealth advisor, at Strategic Wealth Partners. That will provide a boost to stocks.
"The schedule that (Bernanke) laid out is not going to be realized as quickly as he said," Gabrielsen said. "I don't think the economy can handle it."
Payroll processing firm ADP said that U.S. employers added 188,000 jobs in June, more than the 155,000 forecast by economists. Also, the government's weekly report on unemployment claims provided more evidence that layoffs remain low and job gains steady. The number of Americans seeking unemployment benefits fell 5,000 to 343,000.
In U.S. government bond trading, the yield on the 10-year Treasury note was unchanged at 2.48 percent from Tuesday.
In Europe, stock markets slumped after the yield on Portugal's benchmark 10-year bond surged almost a percentage point to 7.31 percent. Investors are worried about the future of the bailed-out country and its efforts to get a handle on its debt after two Cabinet members quit.
Germany's DAX index fell 1 percent to 7,829 and the U.K.'s FTSE 100 fell 1.2 percent to 6,229.
The price of oil climbed $1.43, or 1.5 percent, to $101.03. Oil has climbed almost 8 percent since Monday last week. The price of gold rose $8.50, or 0.7 percent, to close at $1,251.90.
Among stocks making big moves:
— Alcoa fell 9 cents, or 1.2 percent, to $7.71 after the Citigroup analyst Brian Yu reduced his second-quarter and full-year profit predictions for the aluminum producer, citing low prices for the metal.
— AutoNation gained 71 cents, or 1.6 percent, to $45.27 after Credit Suisse raised its rating on the stock to "outperform" from "neutral," citing a positive outlook for the company's parts and servicing business.
— Mead Johnson fell $6.05, or 8.1 percent, to $68.85 adding to a 5.7 percent slump Tuesday. The Chinese government is investigating the nutritional products maker for possibly violating anti-monopoly laws in its pricing of infant formula, Bloomberg News reported yesterday.