By Anna Isaac and Caitlin McCabe

U.S. stocks wavered Monday as investors tried to assess how a rise in coronavirus-infection rates in some states may disrupt signs of a nascent economic recovery.

All three major indexes fell shortly after the opening bell before paring their losses and gaining in midmorning trading. The Dow Jones Industrial Average was recently up about 15 points, or 0.1%. The S&P 500 added 0.1%, while the Nasdaq Composite rallied 0.5%, driven by gains among large-cap technology stocks.

Stocks are attempting to continue last week's rally, during which all three indexes ended the week up 1% or more. However, looming uncertainties surrounding the coronavirus pandemic, relations between U.S. and China and the November election have begun to weigh more heavily on investors. Data shows that infections have picked up pace in Arizona, South Carolina, Florida and Texas.

A widespread rally among U.S. stocks, extending beyond the large-cap technology companies that initially sparked a bounceback, has helped the major equity benchmarks erase most of their losses for this year. The S&P 500 is down just 4% year-to-date, and technical measures are now suggesting that stocks have more scope to climb in the months ahead.

"The market rally we've seen in recent months is firming up," said Seema Shah, chief strategist at Principal Global Investors. "We may not see sharp moves higher, but the economic data is starting to catch up with market performance."

Economic indicators such as jobless claims and retail sales have in recent weeks offered traders confidence that economic activity is picking up after weeks of widespread shutdowns. Yet there are still signs that the recovery has a long way to go.

On Monday, fresh data showed that sales of previously owned homes dropped 9.7% in May from the prior month, as the coronavirus pandemic prevented shoppers from taking advantage of the typically busy spring homebuying season. Economists surveyed by The Wall Street Journal expected an 8.8% decline.

Investors seemed to shrug off the news, with stocks turning from negative to positive shortly thereafter. Beyond big technology stocks, some cyclical stocks also rallied. Companies including Gap and Chipotle Mexican Grill rose, gaining 7.5% and 2.8%, respectively.

"The data is suggesting that households are starting to feel confident again about going about their business," Ms. Shah said. "As long as the rise in the coronavirus cases doesn't put them off, then the economic recovery in the second half of the year may be stronger than anticipated."

The Trump administration is preparing for a fresh wave of cases, according to White House trade adviser Peter Navarro. A second wave of infections isn't necessarily expected, but the government is stockpiling drugs and equipment in case infections resurge in the fall, Mr. Navarro said Sunday.

Still, among Monday's gains, there were big losses, too. American Airlines fell 5.6% after the U.S. carrier said Sunday that it plans to raise $3.5 billion in debt and equity to boost its liquidity and help maintain operations through the pandemic. Rivals United Airlines Holdings and Delta Air Lines also dropped.

In bond markets, the yield on the 10-year U.S. Treasury ticked down to 0.676%, from 0.696% Friday.

In Europe, oil-and-gas companies and travel and leisure stocks were among the worst performers. That left the pan-continental Stoxx Europe 600 wavering between gains and losses before it edged down 0.7%.

Payments company Wirecard plunged 43%, making it the worst performer among major European stocks. The troubled German business said early Monday that the $2 billion that banks were supposedly holding on its behalf probably doesn't exist.

Deutsche Lufthansa and British Airways's parent, International Consolidated Airlines Group, were also among the biggest losers in the region Monday. Lufthansa faces opposition from a major shareholder for its planned bailout agreement with the German government, according to Adrian Yanoshik, senior analyst at Berenberg Bank. The German airline fell 3.8%.

In Asia, most major equity benchmarks dropped by the close of trading. Hong Kong's Hang Seng Index was among the biggest losers, down 0.5%. India's S&P BSE Sensex, meanwhile, gained 0.5%.

Write to Anna Isaac at anna.isaac@wsj.com and Caitlin McCabe at caitlin.mccabe@wsj.com