U.S. stock markets largely reversed two days of losses Friday, offering a sliver of hope amid otherwise disappointing economic data that has stoked fears of a slowdown in the recovery.

The markets were buoyed Friday by surprisingly strong earnings by blue-chip heavyweights General Electric, McDonald’s and Microsoft. About 80 percent of the companies that have reported profits this season have outpaced expectations, according to Thomson Reuters. The positive results across a wide swath of sectors helped turn around a two-day losing streak Friday and shake off broader concerns about the global economy.

“Earnings matter,” said James Cox, managing partner at Harris Financial Group. “When you’re buying stocks, you should be buying based on their earnings, not on a cloudy day in Spain.”

The Dow Jones industrial average finished the week up 1.4 percent at 13,029.26, while the broader Standard & Poor’s 500-stock index rose 0.6 percent this week. The tech-heavy Nasdaq dipped 0.4 percent.

Microsoft was the biggest mover in the Dow after announcing late Thursday that its revenue rose 6 percent during its most recent quarter. Its stock jumped more than 4 percent percent Friday to close at $32.42. McDonald’s reported a 5 percent increase in profit Friday and said traffic to its U.S. locations was “robust.”

General Electric’s stock gained 1 percent even though its profit was down. The results still were better than analysts had expected, and chief executive Jeffrey Immelt said the company remained on track for double-digit growth for the year. With businesses touching almost every sector of the economy — from appliances to health care to gas turbines — GE’s performance amounted to a vote of faith in the global recovery. Still, Immelt injected a note of caution.

“We don’t take the environment for granted,” he said in a conference call with analysts. “We continue to be vigilant in risk management in a volatile world.”

Investor confidence took a blow earlier this week when the government reported that the number of people applying for unemployment benefits last week did not fall as much as analysts expected. Other data also showed a decline in existing-home sales in March and a slowdown in manufacturing.

Still, the Dow’s solid gains this week gave analysts hope that more positive earnings next week would continue to boost the markets.

“Market reactions are very quick,” said Fred Dickson, chief investment strategist for D.A. Davidson. “It’s kind of a sigh-of-relief rally that the numbers may be a little better than expected.”

Such mixed signals not only manifest as market fluctuations but also contribute to what the economic counsellor for the International Monetary Fund has called the world’s “roller coaster” economy.

Signs of strength in the United States, continued growth in the emerging markets and a recent calming of financial tensions in Europe prompted the IMF this week to raise its global growth forecast.

Yet officials gathered in Washington this week for the organization’s policy meeting have spent much of their time raising money for new crisis-fighting funds for Europe and the IMF, concerned that any bump in the road — a spike in oil prices, a bad employment report in the United States, renewed debt tension in Europe — could prove devastating.

The overall mood has been optimistic, but the conversation is still littered with adjectives such as “weak,” “fragile” and “volatile.”

Still, all of the major indexes are up for the year. And Cox said he was encouraged that weekly jobless claims remain below 400,000.

“The economic data is coming in a little weaker, but the trend line is still intact,” he said.