JERUSALEM — Four hundred Israelis looked at their cellphones Wednesday night and discovered just how closely their government is keeping tabs on them during the coronavirus crisis.

The country’s Health Ministry had sent tailored text alerts telling citizens that a digital review of their movements showed they had been in proximity to a person known to have tested positive for the virus.

It was not just an advisory. The text also delivered an instant quarantine order, in keeping with ever-tightening restrictions dictated by the Israeli government. “You must immediately go into isolation [for 14 days] to protect your relatives and the public,” the notice said.

Israelis who have tested positive also received messages informing them that their cellphone data would now be used to warn others who may have been exposed to them, according to a statement from the Health Ministry.

The recipients of these messages had not signed up for the tracking system. No one can opt out. And more waves of these messages could come as the epidemic continues to ripple across the country.

The Israeli initiative represents the most far-reaching step yet by a government in deploying the vast surveillance power that access to cellphone data provides and using it to detect and contain the public health threat posed by the coronavirus.

The program has sparked a clash of imperatives — taking every measure to control a pandemic vs. maintaining civil liberties in a democracy. Late Thursday, the Israeli Supreme Court issued a temporary injunction, allowing only those who test positive to be tracked, and ruled that a parliamentary committee would have to endorse the initiative by Tuesday or it must be shut down.

Even for some caught up in the digital dragnet, it is hard to know how to strike the balance.

“It is not a pleasant thing, but I guess I can understand why they are doing this,” said a man who received one of the notices and is now in isolation. Omer, a 37-year-old from central Israel, asked that his last name not be used, out of privacy concerns.

“My main concern is about the process of how the government made the decision,” he said. “I think it was done for a good cause, so I guess I can support that, but I would have liked to have seen a better decision-making process for taking this pretty extreme measure.”

In parts of Asia, digital tools and other high-tech tracking have been used to fight the spread of the virus.

South Korea's government posts a “travel log” of patients before they were diagnosed with the virus, retracing their steps using tools such as GPS phone tracking, credit card records and surveillance video. Singapore hosts a website that includes the age, gender and occupation of all its coronavirus patients and where they traveled recently. China’s massive surveillance state, which utilizes tools including facial-recognition technology and the Communist Party’s neighborhood committees, has been mobilized to keep close tabs on all movement and enforce quarantines and other measures.

U.S. officials have been exploring tactics similar to Israel’s through potential partnerships with technology companies. But such moves are being eyed warily by privacy advocates, who warn that location data, if not handled with appropriate safeguards, could reveal an individual’s friendships, sexual relationships, political activity, religious convictions and physical movements, and could be used by other government authorities long after the public health emergency has passed.

The White House has been in negotiations with major technology companies, including Google and Facebook, about potentially using aggregated and anonymous location data created by smartphone use, The Washington Post reported Tuesday, but those efforts have been kept largely from the public.

Sen. Edward J. Markey (D-Mass.) sent a letter Thursday seeking answers about potential partnerships between the federal government and private companies.

“Although I agree that we must use technological innovations and collaboration with the private sector to combat the coronavirus, we cannot embrace action that represents a wholesale privacy invasion, particularly when it involves highly sensitive and personal location information,” Markey wrote to Michael Kratsios, the government’s chief technology officer. “I urge you to balance privacy with any data-driven solutions to the current public health crisis.”

The U.S. government has broad authority to request personal data in the case of a national emergency but does not have the legal authority, except in criminal investigations, to insist that companies turn it over, said Al Gidari, director of privacy at Stanford Law School’s Center for Internet and Society.

With appropriate safeguards, Gidari said, the potential use of location data to combat the coronavirus is “a real opportunity to do something positive with the technology and still protect people's privacy.”

The Israeli program is part of a push by Prime Minister Benjamin Netanyahu’s government to employ surveillance tools usually reserved for crime-fighting and counterterrorism in the effort to slow the spread of covid-19.

Earlier this week, the government approved the measure in a late-night telephone call, giving Israel’s Internal Security Agency, the Shin Bet, the power to use its advanced cyber-tracking capabilities to reach suspected carriers of the virus and monitor those meant to be in isolation. The government has not disclosed the exact criteria used in deciding whom to notify.

Israeli authorities said Thursday there were an estimated 677 confirmed cases of covid-19, with no reported deaths.

The government had already imposed tight restrictions, largely confining Israelis to their homes except for grocery buying and medical care.

Civil liberty groups and political opposition leaders condemned the cellphone tracking initiative as a draconian violation of privacy, one made unnecessary by the strict limits already in place.

With public gatherings of any kind prohibited, opponents of the program and what they say are other anti-democratic moves by Netanyahu's government organized a protest convoy Thursday. Hundreds of cars bearing posters and black flags headed for Jerusalem, according to local media reports, before being stopped by police outside the city.

The Supreme Court’s injunction came after an emergency hearing Thursday to consider a legal petition filed by advocacy groups against the tracking.

“These 400 notices show that every citizen of Israel can be surveilled anywhere at any minute in violation of the right to privacy and dignity,” said Suhad Bishara, a senior attorney for Adalah, the Legal Center for Arab Minority Rights in Israel, one of the groups that filed a petition. “The security services now have free hand.”

Hours after Netanyahu’s cabinet approved the controversial tracking program, opposition leader Benny Gantz tweeted: “These are exceptional times that, unfortunately, call for exceptional measures to save lives. That said, we cannot surrender transparency and oversight.”

The surveillance program has entangled Israel’s health crisis with its political crisis. Gantz on Monday was formally given the mandate to try to form the next government. But efforts by his Blue and White alliance to establish parliamentary committees and elect a new parliamentary speaker — replacing the chairman appointed by Netanyahu’s Likud party — were blocked this week by Likud, which insisted that the parliament observe the coronavirus restrictions.

Gantz and other critics maintain that Netanyahu is using the virus to undermine the country’s democratic process and slow the transition to a new government and parliament.

“So under pretext of fighting corona, he has closed the Israeli parliament, ordered people to stay in their homes, and is issuing whatever emergency decrees he wishes,” historian Yuval Noah Harari said in a tweet. “This is called a dictatorship.”

But defenders of the tracking program said the coronavirus epidemic is limiting traditional privacy rights for everyone.

“The contagious nature of this disease means that people’s freedom and civil liberty affects others. Normally we go outside and don’t hurt anyone, but in this situation we might,” said Eugene Kontorovich, director of the Jerusalem-based Kohelet Policy Forum and a law professor at George Mason University outside Washington. “Normally having our cellphone information kept private does not hurt anyone,” he said. “But if you carry the disease and the Health Ministry can’t contact those who you might have infected, then it is dangerous.”

In interviews with Israeli media, Public Security Minister Gilad Erdan said authorities would use the information only for warning those who might be infected and ordering them to self-quarantine. He said that the data would be destroyed.

Craig Timberg in Washington contributed to this report.