By Caitlin Ostroff and Michael Wursthorn

The S&P 500 fell Friday, on pace to snap a recent run of gains, after President Trump said he and the first lady tested positive for coronavirus.

The overnight development jolted investors and added to the political uncertainty about a month ahead of the election. For now, some investors' initial impulse has been to sell stocks, pare back risk as they grapple with the implications of President Trump's infection.

Despite the pressure, stocks recovered some ground to bounce off their session lows after House Speaker Nancy Pelosi said Mr. Trump's prognosis changed the dynamics of aid talks with Republicans. She added she believes lawmakers will eventually reach a deal. She also issued a statement asking airlines to hold off on furloughs and firings as Congress works on an aid package for the industry, sending shares of those companies higher.

The S&P 500, as of 4 p.m. ET, was down nearly 1%, snapping a two-day winning streak. The Dow Jones Industrial Average cut its loss to 134 points, leaving the blue-chip index at 27683 and paring an earlier decline of more than 400 points. The Nasdaq Composite suffered bigger losses amid a retreat from tech stocks, falling 2.2%.

The Cboe Volatility Index, a measure of expected swings in the S&P 500, rose more than 2%.

Investors' concerns range from how the government will function if President Trump's condition worsens and whether other senior government officials are at risk, some analysts said. There are also worries about whether the development raises the stakes of a contested election or a delay, others added.

Not long after markets opened, chief of staff Mark Meadows told reporters that Mr. Trump was showing mild symptoms and remained in good spirits.

"Markets hate uncertainty," said Lisa Erickson, head of the traditional investment group at U.S. Bank Wealth Management who predicts even more volatility for markets in the final stretch of the election season.

Tom Lee, managing partner at Fundstrat Global Advisors, called the Friday selloff a knee-jerk reaction in a note to clients.

But Mr. Lee said there could be a silver lining: Mr. Trump falling ill repudiates skeptics of masks, personal protection gear and social distancing. That could help contain the recent surge in cases and might push down the path of cases.

New coronavirus cases in the U.S. topped 40,000 for the third day in a row. Total confirmed cases in the U.S. rose to nearly 7.28 million, while the death toll approached 208,000, according to data compiled by Johns Hopkins. Those developments have also been weighing on markets, analysts have said.

Investors were also parsing data showing job creation slowed last month. Employers added 661,000 jobs in September, below economists' expectations of about 800,000 and the first time since April when net hiring was below 1 million.

On one hand the data solidified the view that economic activity continues to rebound albeit at a slowing rate. On the other, it doesn't include the glut of layoffs announced by companies in recent days, including Disney, American Airlines and Allstate, potentially putting a dent in job creation for October.

Even with Friday's losses, all three major indexes ended the week higher. The Dow and the S&P 500 were up 1.9% and 1.5%, respectively, over the past five trading days -- their first weekly gain in five weeks. The Nasdaq was also up 1.5%.

Tech stocks bore the brunt of Friday's selloff, as investors pulled back from the market's most overheated sector. Shares of Apple fell 3%, Adobe slid 4% and several chip makers racked up losses north of 2%.

Travel stocks recouped some ground after Mrs. Pelosi's comments. Carnival reversed its loss to rise 1% in recent trading. Airliners Delta Air Lines and American Airlines Group rose 2.1% and 3.3%, respectively.

Investment firm Invesco, meanwhile, rose 5.4% after The Wall Street Journal reported that shareholder activist Trian Fund Management has taken big stakes in it and Janus Henderson Group and plans to agitate for deal making aimed at building a rival to the biggest asset managers in the world.

Investors sought safety in some of the traditional market veins. Utility stocks rose 0.7% in recent trading, while real-estate stocks added 1%. Bond yields also rose, paring a slide from earlier in the session. The yield on the 10-year U.S. Treasury note was recently at 0.702% after settling at 0.677% Thursday.

In the final month of the 2020 campaign, Mr. Trump will need to cancel in-person events, potentially including the next debate with Democrat Joe Biden set for Oct. 15. The president's age of 74 puts him at higher risk from the virus.

"It just creates a wider range of outcomes or changes the probabilities of the election," said Hani Redha, a portfolio manager at PineBridge Investments. "It injects a lot of uncertainty of how it plays out."

Mr. Biden -- who has had a lead in the polls so far -- could benefit from continuing to campaign while Mr. Trump is sidelined," Mr. Redha said. "If this does put Trump out of action, but not Biden, then those odds will only continue to move in that direction."

Overseas, the Stoxx Europe 600 edged up 0.2%.

Stock benchmarks in Tokyo, Australia and Singapore all fell, dropping between 0.7% and 1.4%. Markets in Shanghai, Hong Kong and South Korea were closed for holidays.

Write to Caitlin Ostroff at caitlin.ostroff@wsj.com and Michael Wursthorn at Michael.Wursthorn@wsj.com

(END) Dow Jones Newswires

10-02-20 1620ET