Possibly averting a court battle, Maryland’s largest county on Friday backed off a controversial ban on in-person instruction at private schools.

Montgomery County Health Officer Travis Gayles rescinded both of his orders calling for online-only teaching, saying the state’s latest effort to thwart the ban gave him no option, despite his standing concerns about the novel coronavirus pandemic.

Gayles “continues to strongly advise schools against in-person learning due to the risks posed by COVID-19,” the county said in a statement, adding that the health officer has asked the state to provide criteria for governments to determine on a case-by-case basis when private schools can safely operate.

The announcement appears to resolve, for now, a protracted battle between Maryland Gov. Larry Hogan (R) and one of the state’s most liberal jurisdictions — a fight that sparked a week of brinkmanship and a federal lawsuit by parents challenging the closures that is scheduled for a hearing next week.

The county’s retreat resolves some uncertainty for the approximately 32,000 students of nonpublic schools in Montgomery. But it is still not clear whether all private schools that want to open will be granted approval to do so, nor which safety rules they would have to follow.

The episode remains a proxy for broader debates on the rights of private schools, economic and racial equity in education, and whether a state can effectively combat the deadly virus once health directives become politicized.

Hogan spokesman Michael Ricci said state officials will provide guidance next week on how to evaluate private schools’ plans to reopen.

The lack of established criteria to determine what’s safe — especially as the state continues to log hundreds of new coronavirus cases daily — was a key reason that Montgomery officials cited in issuing a blanket closure order.

Montgomery County Executive Marc Elrich (D) said Gayles concluded on Friday that the county no longer had that option after reviewing the state’s most recent memo, which explicitly barred blanket closures of private schools. “Rather than to fight it, we made the decision to rescind it,” Elrich said.

Elrich added that he has told state officials that the county will need additional support to ensure nonpublic schools reopen safely.

“We have, at minimum, 140 private schools, and they need to be inspected more than once,” he said. “I don’t have people lying around doing nothing who can go do that. . . . We’re going to need resources, and we’re going to need support.”

Coronavirus infections have plateaued in Montgomery since mid-June, but they rose statewide in July. Within the county, there are still 91 new cases a day on average. Gayles said that number would need to be fewer than 10 for reopening to be safe.

Private school parents cheered the news that their children might be able to return to their classrooms this fall for the first time since March.

“It’s a relief, but it’s scary that it had to come to this,” said Mary Beth Albertini, who has two daughters at Bullis, a private K-12 prep school in Potomac with about 800 students last year.

Albertini said she did not know where Bullis’s plans for fall stood, but she said the school had previously intended to pursue in-person learning to some degree, following Centers for Disease Control and Prevention guidelines and putting in place safety measures.

“My kids will be thrilled,” she said. “They are excited to go back.”

Christina Marmor, who sends her two children to Holy Redeemer Catholic School in Kensington, a small parish school that educates students in prekindergarten to eighth grade, said she is “elated.”

Marmor said in-person instruction is especially important for her eldest child, who is deaf and uses cochlear implants. She had not heard anything from her school yet but was hoping for the best.

“We’ve been on a roller coaster of emotion over the past week,” she said.

Montgomery County’s public schools, like nearly all in Maryland, will open with online instruction only.

But the legal fight may not necessarily be over, depending on what guidance the state issues to determine how to safely reopen private schools.

In a letter to State Health Secretary Robert R. Neall on Friday, Gayles asked state officials to provide clear guidelines for local jurisdictions to decide how to lift coronavirus restrictions, including at schools. He said he had written to Neall on Tuesday but received no response.

Hogan, an advocate for private schools, had twice maneuvered to strip power from Gayles, who last week ordered all private school campuses closed at least through Oct. 1. Regardless of safety precautions taken by individual schools, Gayles had argued, there are still far too many coronavirus cases in the community to allow students and teachers to gather indoors for long periods of time.

It is the latest example of the liberal, affluent county of 1 million bucking Hogan on the virus. Montgomery reopened businesses and public gathering places more slowly than other parts of the state, and Gayles sent an email on behalf of six county health officers last month urging the state to reimpose restrictions amid a surge of new virus cases statewide. Hogan refused to do so.

On private schools, Gayles first tried to use the power Hogan gave local governments to decide when and how to reopen their communities. Hogan soon revoked that power by rewriting his emergency order to specifically exclude schools.

Private schools and private school parents, meanwhile, sued over Gayles’s ruling.

Bruce Marcus, the private litigator hired to defend the county, said Gayles “has been vilified by those whose personal interests are not aligned with the interest of protecting public health and safety. . . . Dr. Gayles is not a politician. He is a physician and a scientist.”

Montgomery County Public Schools announced in July that the system would begin the academic year online. But private schools, and parents who send their children to them, believe their schools should be treated more like private businesses: not tethered to standards designed for one of the largest school systems in the country. Many private schools spent heavily to retrofit their buildings and drafted carefully designed reopening plans that they say would be safe.

Timothy Maloney, the lawyer representing the private school community, said Gayles’s directive appeared to be the only order of its kind in the country. He accused the county of wanting to avoid dramatically different learning situations for public school and private school students. And he noted that bars, restaurants and other businesses have been allowed to reopen, provided they do it safely.

After the county backed down Friday afternoon, Maloney added: “Wisdom is always welcome, no matter how late it arrives.”

Gayles, a pediatrician who started his medical career studying the impact of violence among minority youths in Chicago, has made health equity a top priority in his current job.

While he has not cited fairness in his decision on private schools, the county last year passed a sweeping racial-equity law that requires lawmakers to consider equity in every bill.

In an impassioned speech on Tuesday, County Council member Craig Rice (D-District 2) warned that students and employees who return to private schools could become “super spreaders” of the disease. That scenario, he noted, would be particularly dangerous for the county’s African American and Latino residents, who have been disproportionately affected by the virus.

Michael Petrilli, a Montgomery County parent who is president of the Thomas B. Fordham Institute, a conservative-leaning education think tank, said private and parochial schools have stronger incentives than public schools to reopen on campus: Their parents can withdraw financial support if they are dissatisfied.

“If these high-end private schools say, ‘We’re not going back until there’s a vaccine,’ a lot of parents might say, ‘Forget that,’ ” he said. “It’s not worth $40,000 a year for Zoom school.”

After Hogan rewrote his health directive on Monday, Gayles reissued his own order, this time under a power granted him by state law. The next day, Thursday, the governor sent a memo to every health officer in the state saying explicitly that blanket closures of private school were against state policy.

Neall, the state health secretary, said each private school should be “provided with the individualized opportunity” to decide how to reopen in the fall. Ricci, Hogan’s spokesman, noted that the governor did not dictate decisions for public schools, either; they have been making decisions based on guidance from Maryland Schools Superintendent Karen B. Salmon. “He’s not trying to make some sort of political statement about private schools,” Ricci said.

But the governor’s critics see him using his political might in ways they say are contrary to the approach he took early in the pandemic, when he allowed local leaders to opt out of reopening if they believed it was not safe.

“Respectfully, I think we should trust the public health experts,” said Del. Eric G. Luedtke (D-Montgomery). “I do not think it’s that big an ask for private schools to start in-person instruction a few weeks later.”

The governor’s allies view it as a slippery slope. Maryland House Minority Leader Nicholaus R. Kipke (R-Anne Arundel) and Whip Kathy Szeliga (R-Baltimore County) have asked Hogan to issue an order declaring all schools essential, a move they say will allow private schools across the state to open.

As Montgomery issued its second health order Wednesday night, parents from private and parochial schools demonstrated — wearing masks and standing apart from each other — behind the county executive’s offices in Rockville. “Our Schools are Safe,” one handwritten poster said. “Let Parents Decide,” said another.

Kevin O’Rourke, a parent who has helped lead the opposition, expressed relief Friday upon hearing that Montgomery had rescinded the order. He noted the day before that in other parts of Maryland, including neighboring Prince George’s County, parents have not had to “fight with their county government to send their children to school.”

Prince George’s Health Officer Ernest L. Carter said in a statement that he is reviewing the safety plans provided by private schools in the county, which leads the state in coronavirus infections. “Data continue to drive our decision-making,” Carter said.

Some Montgomery private schools had already chosen to join the vast majority of the state’s public school systems in launching the year online. Another, Our Lady of Good Counsel High School in Olney, announced Thursday that the year would begin virtually — regardless of how the court battle turns out.

“We know the legal wrangling is not over yet,” the school wrote in a letter posted on the school website. “The to and fro has certainly not made it easier for us to make our decision.”

Rachel Chason contributed to this report.