Wall Street shook off growing fears that a mysterious and fast-moving virus in China could hurt the global economy, even as international markets were hit by those concerns on Thursday.

After an early decline, the S&P 500 staged an afternoon rally to close 0.3 percent higher. The market was buttressed by strong earnings from blue-chip companies including Microsoft, Coca-Cola and Hershey as well as a rally in financial shares.

In recent days, the global economic outlook has darkened in the face of the expanding outbreak.

The vast majority of people infected by coronavirus are in China, but governments around the world are taking steps to contain the disease, and the risk to investors is that those efforts dampen economic activity. Russia closed part of its 2,600-mile border with China on Thursday, and a number of countries have discouraged their citizens from traveling there.

A growing number of companies have warned that they will have to close or shift operations and could take a financial hit from widespread business disruptions in China. Several others say it is too early to tell what the impact will be.