By Avantika Chilkoti

The dollar briefly crept higher as concerns about the rise in new Covid-19 infections in parts of the U.S. and across emerging markets took the edge off the broader market rally of recent days.

The Wall Street Journal Dollar Index, which measures the dollar against a basket of other currencies, ticked up before closing unchanged at 91.23 Tuesday. The gauge, which jumped sharply in mid-March as stock markets tanked, has been hovering between 90 and 95 since.

Analysts expect the dollar to remain at historically high levels -- or even gain -- as recent virus cases dampen hopes for a V-shaped economic recovery once economies reopen.

"Dollar weakness is going to be more difficult to come by now," said James Athey, senior investment manager at Aberdeen Standard Investments.

The dollar, alongside the Japanese yen and Swiss franc, is considered a haven asset that investors buy when stocks fall and the economic outlook turns sour.

A volatile dollar can impact all corners of financial markets. Jittery investors buying up dollar assets in the March rout triggered record capital outflows from emerging markets. A stronger dollar adds to the cost of paying off dollar-denominated debt.

The dollar rose against the Mexican peso and the South African rand Tuesday before retracing gains toward the end of the day.

A wild-card for the dollar is China. The yuan, which is partially managed by Beijing, has strengthened against the dollar in recent days amid signs the economy in China is opening faster than expected. China's stock market has also rallied. The yuan traded for 7.0139 per $1 Tuesday, almost unchanged from Monday.

Richard McGuire, senior fixed income strategist at Rabobank, says the dollar's performance this year has proven its status as a haven, something that could be tested again if U.S.-China tensions flare up.

"In the instance that geopolitical tensions rise so much that China sacrifices its own interest to harm the U.S., that will drive demand for safety more broadly," he said.

Mr. McGuire noted that the dollar's correlation with the stock market was at its highest level since September 2016, indicating that traders see it as a place to shelter when markets retreat.

On average in recent months, for every 1% decline in the S&P 500, there was a 0.37% strengthening of the dollar in trade-weighted terms, he said.

Write to Avantika Chilkoti at Avantika.Chilkoti@wsj.com