By Anna Isaac and Gunjan Banerji

U.S. stocks wavered Friday but ended the week with gains as the latest employment report showed the economy added more jobs than expected last month, though uncertainty surrounding fresh government stimulus threatened to crimp a recovery.

The S&P 500 edged lower for much of the session before turning higher late in the day, eking out a slim gain for the sixth consecutive trading session, the longest such streak since April 2019.

Major indexes rose for much of the week, though their big gains came to a halt ahead of the jobs report and as talks between White House officials and Democratic leaders on a new coronavirus-aid package concluded without a breakthrough. On Friday, those talks were on the brink of collapse.

The latest jobs report showed that employers added 1.8 million jobs in July and the unemployment rate fell to 10.2%, according to the Labor Department. Economists surveyed by The Wall Street Journal had projected that payrolls grew by 1.5 million and that the unemployment rate dropped to 10.6% from 11.1% in June.

Still, there were concerns that the next aid package wouldn't be as robust as the first. Fiscal stimulus has been a key driver in the stock market's dramatic recovery from its March lows, and worries that lawmakers wouldn't reach a consensus stirred volatility on Friday, analysts said.

"We have a lot of wood to chop from here," said Chris O'Keefe, a lead portfolio manager at Logan Capital Management. Still, he said "I think they have to do something."

The S&P 500 edged up 2.21 points, or 0.1%, to 3351.28. The Dow Jones Industrial Average added 46.50 points, or 0.2%, to 27433.48. The tech-heavy Nasdaq Composite shed 97.09 points, or 0.9% to 11010.98, backing away from its record hit Thursday.

The S&P 500 and Nasdaq each added about 2.5% for the week. The Dow gained 3.8% this week.

Also hanging in the backdrop are tensions between the U.S. and countries around the globe. Though stocks edged higher, concerns about the economy and trade were evident in the market for traditionally safer assets like gold. Front month gold futures gained $47.30 a troy ounce, or 2.4%, to $2010.10 this week. It was the ninth consecutive week of gains, the longest such stretch since 2006.

President Trump signed executive orders Thursday night that would bar people in the U.S. or subject to U.S. jurisdiction from transactions with the China-based owners of WeChat and TikTok, effective 45 days from Thursday. That essentially imposes a deadline for an American company to purchase TikTok's U.S. operations. The orders are likely to be viewed in China as an attempt to stifle the nation's technology sector.

The orders come as relations deteriorate between the two countries, prompting speculation that trade among the world's two largest economies could take a hit.

"China is just about the only bipartisan issue in Washington at the moment," said James Athey, senior investment manager at Aberdeen Standard Investments. "The framework of a Cold War, decoupling and a bi-polar world is the right one to think about. It won't be possible to straddle both China's and the U.S.'s agenda."

In addition, Canada said it would place tariffs on U.S. products that contain aluminum, after President Trump placed tariffs on some Canadian aluminum.

In corporate news, shares of Uber Technologies fell $1.81, or 5.2%, to $32.90 after the company posted another big loss after market close Thursday, with little sign of recovery in its core ride-hailing business as the pandemic drags on.

Overseas, major markets fell. The Shanghai Composite dropped 1%, while Hong Kong's Hang Seng Index fell 1.6% and Japan's Nikkei 225 index dropped 0.4%.

Write to Anna Isaac at anna.isaac@wsj.com and Gunjan Banerji at Gunjan.Banerji@wsj.com