Shares of Google also jumped more than 9 percent after Mr. Trump said the administration was working with the company to develop a website to determine whether an individual needed a test — a move aimed at avoiding overwhelming the health system with people who are ill but do not necessarily need to be tested for coronavirus. Google later said the site would initially only be used around San Francisco, “with the hope of expanding it more broadly over time.”

On Friday evening, House Speaker Nancy Pelosi told Democratic lawmakers she had reached an agreement with the Trump administration on a coronavirus relief package. The House was planning to pass it Friday night. The stimulus could help assuage investors’ fears that the economy is on the verge of a recession, especially as dozens of companies ask employees to work from home and cities impose restrictions on people’s movement, which in turn could affect consumer spending.

Investors hate uncertainty and had been looking for some decisive action from the federal government as the coronavirus outbreak, which began in China and has continued to grow exponentially, reaching the status of a pandemic earlier this week. The lack of clarity around the scope and severity of the global outbreak, along with limited and sporadic testing in the United States, had sent financial markets into a tailspin in recent weeks.

At times, the markets acted inconsistently, plunging and then rising, and then plunging again, as each day brought new measures to contain the outbreak and new worries that the economy, workers and businesses would take a hit as a result of them.

Extensive efforts by governments and central banks to steady the ship have so far managed to forestall any major breakdowns in the financial system, but the question now is whether Americans will keep spending.

The latest survey of consumer sentiment by the University of Michigan released on Friday showed that Americans were already slightly less confident in early March compared with February, as fears about coronavirus and its impact on the stock market began to spread. The university will release its next round of data at the end of the month.