By Joe Wallace and Paul Vigna

The S&P 500 rose in the first session of July after data showed the labor market continued to improve last month.

The nonfarm private sector created 2.4 million jobs in June, with 70% of new jobs in the leisure, hospitality, trade and construction industries, according to the ADP National Employment Report.

"The first half was surprise after surprise," said Lindsey Bell, the chief investment strategist at Ally Invest. "Now we're starting to get surprises to the upside. I think the second half will be all about making sure that the recovery continues at a solid clip."

The S&P 500 climbed 15.57 points, or 0.5%, to 3115.86, after rising 20% over the past three months for its best quarterly performance since 1998. The rally was fueled by the Federal Reserve's aggressive support for financial markets and signs of an early recovery in economic activity.

The technology-heavy Nasdaq Composite gained 95.86 points, or 1%, to 10154.63. The Dow Jones Industrial Average lost 77.91 points, or 0.3%, to 25734.97.

In another piece of encouraging economic data, the Institute for Supply Management's June manufacturing index rose to 52.6 from 43.1 in May. That was better than consensus expectations. Numbers above 50 indicate expansion.

That followed similar results in the overseas surveys. Factories in Asia and Europe continued their return to normality in June as restrictions designed to contain the coronavirus were lifted, according to surveys of purchasing managers. Manufacturing sectors returned to growth in a number of countries, including France, the U.K., Malaysia, Vietnam, Australia and Ireland.

Whenever stocks have the kind of quarter they just had, the following quarter tends to be a strong one as well, said Frank Cappelleri, the executive director of Instinet. The last seven times the S&P 500 rose 15% in a quarter, it rose an average of 9.5% in the next quarter, he said.

This volatile year makes predictions hard, of course. Mr. Cappelleri noted the market was largely rangebound for the past month and could remain so.

"More of that is not the worst-case scenario," he said.

Ms. Bell of Ally agreed trading in the weeks and months ahead could be choppy as investors try to digest another earnings season, the pace of the recovery and the pandemic, as well as the search for a coronavirus vaccine.

"On top of all that, they're going to have to start thinking about what happens with the election," she said.

There were other upside surprises on Wednesday, too. FedEx shares jumped 12% to $156.66 after the company reported Christmas-like levels of spending in its latest quarter. FedEx said it is seeing tentative signs that the global economy is recovering from the pandemic.

Shares of Pfizer rose 3.2% to $33.74 after the company reported promising results from a trial of its coronavirus vaccine candidate.

Shares of YRC Worldwide surged 75% to $3.23 after the U.S. Treasury said it would lend the trucking firm $700 million in coronavirus stimulus funds.

Tesla's recent gains have made it the most valuable car company in the world by market capitalization. Shares of Tesla rose 3.7% to $1,119.63 on Wednesday, pushing its market cap to $207.66 billion, past Toyota Motor's $201.99 billion market cap.

In the afternoon, the release of the Federal Reserve's minutes of its June meeting showed officials expect to keep interest rates near zero at least through 2022. Central bank officials at the meeting also reviewed how to design more support for the economy.

The yield on 10-year Treasury notes ticked up to 0.682% from 0.653% on Tuesday.

Fed Chairman Jerome Powell told Congress Tuesday that spending and other forms of economic activity have rebounded from lockdowns faster than the central bank expected. However, a second outbreak of coronavirus would undermine public confidence and jeopardize parts of the economy that rely on people gathering in groups, he added.

The U.S. is now recording roughly 40,000 cases a day of coronavirus. New daily cases could hit 100,000 if people continue to flout advice on social distancing and face masks, Anthony Fauci, the nation's top infectious-disease doctor, said this week.

That's led other investors to become more cautious about the outlook for the U.S. economy . High levels of saving suggest that the record jump in retail sales that took place in May is unsustainable, said Andrea Carzana, a fund manager at Columbia Threadneedle Investments.

"I struggle to see that there won't be a longer-term impact on consumers following the opening of the economy," Mr. Carzana said. He added he expects defensive technology and pharmaceutical stocks to keep rising and shares that are sensitive to the state of the real economy, particularly those of banks, to retreat.

Stocks rose in Europe after markets in much of Asia also closed higher. The Stoxx Europe 600 added 0.2% to 361.19. The gauge climbed almost 13% in the second quarter, after having seen 23% of its value wiped out in the first three months of the year.

China's CSI 300 index gained 2% to 4247.78 after a private gauge of manufacturing activity rose to a six-month high, boosted by increased domestic demand. Hong Kong's stock market was closed for a public holiday.

Write to Joe Wallace at Joe.Wallace@wsj.com and Paul Vigna at paul.vigna@wsj.com