OTTAWA — Prime Minister Justin Trudeau reversed his government’s open immigration stance and said Canada would begin turning back asylum seekers who walk in from the United States outside of official border crossings.

The move, which takes effect at 11:59 p.m. Friday, came as the countries prepared to close their mutual border for the first time since Canada became an independent nation and as countries around the world seal themselves off to limit the spread of the coronavirus.

“This is a temporary measure which we’ll put in place for as long as the coronavirus crisis lasts,” Mr. Trudeau said only days after his government said such asylum seekers would only be quarantined. “These are exceptional measures to protect citizens.”

By Friday afternoon 929 coronavirus cases had been reported in Canada, although that figure was rapidly rising. There have been 11 deaths.