San Francisco officials are allowing cannabis businesses to remain open while many other stores are shut down over the next three weeks as the city goes to extreme lengths to fight the coronavirus pandemic.

City officials originally told cannabis stores they had to close on Tuesday because of the city’s order one day earlier to close nonessential businesses and have residents stay at home as much as possible. But then the San Francisco Department of Health sent a tweet Tuesday afternoon saying that dispensaries could stay open after all.

The point was later reiterated by Mayor London Breed and Dr. Susan Philip, director of disease prevention and control in the city’s public health department, in a news conference.

“People rely on medical cannabis for chronic pain, seizure disorders, muscle spasms, depression and multiple other disorders and conditions,” Philip said. “So I want to clarify ... that cannabis dispensaries are allowed to remain open for pickup or delivery of these essential medical treatments.”

Philp said the city would prefer that residents use delivery services but they will also be allowed to visit dispensaries in person.

The initial directive had frustrated businesses and advocates who want cannabis to remain available, especially for medical patients, while residents in San Francisco and other Bay Area counties shelter in place until at least April 7.

Restaurants were allowed to offer delivery and takeout, but the same was not true for San Francisco’s cannabis businesses at first. An email sent Tuesday afternoon by the city cannabis office and public health department said businesses should be closed Tuesday but signaled that changes could come soon.

In the meantime, some of the city’s most visible cannabis operations were temporarily shuttered.

“For now we are completely closed,” said Eliot Dobris, a spokesman for the Apothecarium dispensary, which has three locations in San Francisco. “We have raised the issue of access for medical patients and are in ongoing discussions with the city. Many of our guests with true medical needs have not bothered to get medical cards over the last couple of years, since recreational use became legal.”

In an email after the city revised its stance, Dobris said the Apothecarium would be “restarting sales as soon as possible.”

Other dispensaries that stayed open in the Bay Area forced customers to separate themselves as mandated by the health orders. Harborside’s Oakland dispensary said Tuesday on Twitter that it had “limited in-store capacity for social distancing.”

Eaze, the San Francisco on-demand cannabis delivery service, also suspended service in the city on Tuesday following the original direction of local officials. On Tuesday evening, Eaze said it would resume operations in San Francisco on Wednesday following statements from the mayor and public health department.

San Francisco public health and cannabis officials had told businesses in an email Tuesday afternoon that “the situation is fluid” and they were working to “craft a strategy that will allow for access to healthy and safe product.”

The initial attempt to close cannabis shops drew strong criticism from Supervisor Matt Haney, who called it a “huge mistake” that “should be reversed.”

“Many people rely on cannabis as a medicine: people in pain, people in chemo,” he said.

He later said on Twitter that city public health officials had “reversed their decision” and said the move to keep cannabis businesses open was “important.”

The reversal will be important for people like Troy Brunet, a medical cannabis patient for 10 years who makes a purchase every two or three days.

He said he lives on a fixed income and can’t afford to stockpile. Brunet, a San Francisco resident, said he is HIV positive and uses cannabis to treat nausea.

“I was able to purchase two cartridges ... that will hold me five or six days — let’s hope,” Brunet said. “I’ll have to stretch everything to the limit and pray for the rest. My nausea is going to be unbelievably frustrating.”

Dobris, the Apothecarium spokesman, said Monday that the company had added numerous precautions to protect customers and staff.

“We have hand sanitizer stations prominently set up, and team members have been reassigned to clean and disinfect continuously — including counters, door handles, tabletops, ordering kiosks and ATMs.” Apothecarium staff were also asking customers to maintain social distance inside their stores and not allowing them to touch samples or sniffer jars.

Long lines were reported at cannabis stores in San Francisco and the East Bay because of the shelter-in-place orders.

At Berkeley Patients Group on San Pablo Avenue on Monday, before the orders took effect, there was a line of about 40 people at 6 p.m. It was somewhat fraught at times, with people yelling at one another for getting in the wrong line or cutting. Many people were stocking up, buying several eighths and packages of edibles in anticipation of the closures ahead.

Chronicle staff writers Janelle Bitker and Michael Cabanatuan contributed to this story.

Marcus Crowder is a Sacramento freelance writer. J.D. Morris is a San Francisco Chronicle staff writer. Email: jd.morris@sfchronicle.com Twitter: @thejdmorris