The rest of the country recoiled at the sight of a New York license plate. Florida and Rhode Island singled out New York travelers, who researchers now believe helped to seed the spread of the virus in other states.

But as New York has largely controlled its outbreak, the tables have turned. Gov. Andrew M. Cuomo on Wednesday announced that anyone coming to New York from a state currently hard hit by the virus would have to quarantine for two weeks.

The restrictions were based on specific health metrics related to the coronavirus, Mr. Cuomo said. At the moment, travelers from nine states — as well as New Yorkers returning from those states — would have to quarantine.