With Beijing and Shanghai struggling to control Covid-19 outbreaks, China’s pandemic strategy faces a moment of truth.

The highly infectious Omicron variant of the coronavirus has shut down Shanghai for more than a month. Its threat to do the same to the country’s capital is fueling debate over whether China needs to shift its zero-tolerance approach.

Most of Shanghai’s 25 million residents remain confined to their homes, with little expectation of a quick return to normal life. Daily new infections have fallen in recent days, but public-health experts say any loosening of control measures could prompt a resurgence, overwhelming the healthcare system and exacting an unacceptably high toll on the elderly and unvaccinated.

Meanwhile, in Beijing, the country’s all-important political center, schools have been closed and worried citizens have cleaned out supermarkets amid fears a large-scale lockdown is coming to the city of around 22 million.

On Sunday, Beijing reported 59 new locally transmitted infections, up from 54 the previous day, while China’s National Health Commission said it had discovered 8,256 new infections nationwide. Most of cases, 7,872, were still in Shanghai, though new infections there have come down from more than 20,000 a day.

In recent days, Chinese leader Xi Jinping and health authorities have reaffirmed their commitment to the playbook that the country has adhered to for most of the past two years, aiming to quickly suppress any outbreaks through a regimen of mass testing and quarantining of infected patients.

A Covid-19 testing site on Saturday in Shanghai, home to most of China’s new infections.

Photo: ALY SONG/REUTERS

Public-health officials have been told to regard Shanghai’s struggles as a warning against looser controls and that the leadership, at least for now, plans to continue the current approach until at least the Communist Party Congress in the fall when Mr. Xi is expected to secure a third term as China’s leader, according to people working at China’s Center for Disease Control and Prevention.

China’s National Health Commission in response to a request for comment referred to its news briefings. In one of those on Friday, a senior official said it was important that action be consistent across the country and warned that local outbreaks, if badly controlled, could easily spread across China.

The people working at China’s CDC said employees have been told by superiors to refrain from publicly criticizing or raising alternatives to China’s Covid-19 strategy to avoid undermining the morale of officials and ordinary Chinese in fighting Covid-19.

Behind closed doors, however, some top-level public health experts in China have argued that the current zero-tolerance approach is unsustainable, the people said.

On April 25, members of the National Health Commission and China’s CDC discussed in an internal meeting the lessons learned from Shanghai’s travails and the need to explore home quarantine for mild and asymptomatic cases, said one of the people. That would represent a loosening of China’s current practice of sending anyone who tests positive, regardless of severity, to designated quarantine facilities.

Delivery drivers crowded at the takeout window of a Beijing restaurant on Sunday.

Photo: Kevin Frayer/Getty Images

Hu Xijin, the former top editor of nationalist tabloid Global Times and a widely followed commentator, laid out the stakes in a recent post, describing Beijing’s ability to contain the current wave of cases as a make-or-break moment for China’s “zero-Covid” approach.

He told his 24 million followers that the outcome in Beijing will show whether “Omicron is so powerful that it can break through any human-erected barrier”—or whether Shanghai simply made preventable mistakes. If Beijing can’t control the current outbreak, he added, “then the Chinese understanding of the virus will likely be reshaped.”

China’s economy is already paying the price, and many economists are now skeptical the country will be able to achieve its 5.5% growth target this year if it sticks to its strict Covid-19 approach, even as Mr. Xi pushes for China to top the U.S. in gross domestic product growth this year.

Shanghai’s struggle against rising Covid-19 infections upended a fledgling experiment with adapting the approach earlier in the year.

In February, Shanghai and the southern tech hub Shenzhen were given leeway to experiment with more-targeted and less-intrusive measures to bring local outbreaks under control.

While Shenzhen quickly returned to normalcy, Shanghai has tallied hundreds of thousands of infections and several hundred deaths and remains mired in a lockdown with no clear exit date.

Public-health experts, after studying their two different outcomes, concluded that a swift and short lockdown together with mass testing early on in the outbreak allowed Shenzhen to bring Covid-19 under control, according to the people working for China’s CDC.

Shanghai, by contrast, let time pass while public-health experts and officials argued over whether to lock down the entire city and whether it should allow home quarantine, the people said. Eventually Sun Chunlan, China’s vice premier in charge of pandemic control, delivered Beijing’s decision to impose strict measures. By then, numbers were snowballing.

“It was once a battle that was hard and costly to win,” said one of the people. “Now it becomes one that is almost impossible to win.”

Beijing raced to carry out citywide testing late last month two days after cases began surging, hoping to snuff out the nascent outbreak before numbers would explode. Shanghai, in contrast, waited around two weeks before implementing a citywide screening.

Most of Shanghai’s 25 million residents remain confined to their homes.

Photo: alex plavevski/Shutterstock

Eager to avoid the logistical breakdowns that have plagued Shanghai’s lockdown, authorities have assured residents that food supply is ample after residents stocked up on food and other necessities in preparation for a potential lockdown. On Tuesday, Beijing announced it would start releasing 100 tons of eggs from its strategic reserves to meet public demand.

Many Chinese are still frightened of getting infected and not ready for controls to be eased, said the people working for China’s CDC, adding that there had been discussion of educating the broader public on Omicron’s tendency to cause mostly mild or no symptoms.

Some public-health officials have warned people not to let down their guards, saying that Omicron is still seven to eight times more deadly than the flu. Other officials emphasize the need to get over the fear of Omicron. Public-health experts agree China needs to do more to vaccinate the elderly and most vulnerable.

Maintaining stability is paramount for Mr. Xi, who has presented China’s pandemic performance so far—with relatively lower infections and deaths—as proof that its approach is superior to that of the West.

An editorial in the Chinese Communist Party’s mouthpiece People’s Daily last week pointed to the declining number of new infections in Shanghai as proof the zero-tolerance approach was working.

Still, some public-health officials are pushing for some small easing measures, for example, monitoring the case count in the coastal city of Xiamen, where quarantine time for incoming international travelers was shortened in early April, according to the people working for China’s CDC. Some cities also are debating whether they can cut the number of isolation days for close contacts of infected people, they said.

Home quarantine also has been on the table, the people said, at least for mild and asymptomatic cases and close contacts, and when their living conditions permit it. But some public-health experts worry that making sure patients meet the criteria and follow the rules might tie up more resources than simply sending them to centralized quarantine facilities, they said.

Write to Sha Hua at sha.hua@wsj.com