Chinese factory activity contracted in August, as the world’s second-largest economy struggled to shake off the impact from Covid-19 flare-ups, its worst heat wave in six decades and a deepening real-estate downturn.

Manufacturing activity shrank for a second consecutive month, as extreme weather resulted in electricity shortages and factory disruptions, China’s National Bureau of Statistics said Wednesday.

Wednesday’s data indicates China’s slowing economy isn’t out of the woods yet. The country had shown signs of a nascent recovery in June, after strict pandemic-related restrictions were eased in key regions including the financial hub of Shanghai. But a resurgence of Covid cases in the past month has triggered fresh lockdowns in Chinese cities, while a slump in the property sector drags on.

Prolonged weakness in China’s economy impedes an engine of global growth as major economies already face pressure from soaring inflation and the impact of a prolonged Russia-Ukraine war. Weak demand within China also spells trouble for multinationals such as Apple Inc. and Starbucks Corp., which count on China’s appetite for a range of goods from raw materials to smartphones and coffee for profit growth.

The official manufacturing purchasing managers index edged up to 49.4 in August from 49 in July, exceeding the median forecast of 49.2 among economists polled by The Wall Street Journal. A score of above 50 indicates an expansion in the manufacturing sector; below 50, a decline.

Beijing unexpectedly lowered two key interest rates in mid-August, and the State Council, China’s cabinet, announced a $146 billion stimulus package to shore up growth. Still, many economists expect business investment and consumer spending to remain depressed.

At a key political meeting in July, Chinese policy makers effectively abandoned a growth target of about 5.5%, set earlier this year, amid deepening stress in the property market and sporadic Covid outbreaks.

This month, the country’s economy took a further hit when extreme heat and drought resulted in a power crunch in some provinces, forcing global manufacturers including Foxconn Technology Group and car makers Toyota Motor Corp. and Volkswagen AG to temporarily halt production, depressing factory activity.

Separately, China’s nonmanufacturing purchasing managers index fell to 52.6 in August from 53.8 in July, the statistics bureau said Wednesday. The spread of the coronavirus and bad weather held back growth in both services and construction activity in August, it added.

The services sector represented 53% of China’s gross domestic product in 2021, and sluggishness there didn’t bode well for the economy, economists from ANZ said in a note to clients. The bank cut China’s full-year GDP growth to 3% from 4% after Wednesday’s data release, citing weakening demand at home and abroad.

The country’s strategy of resorting to sudden lockdowns to contain Covid-19 continues to hinder growth. In the past month, Covid flare-ups in dozens of cities have led to mass testing and closure of entertainment and business venues.

Authorities in Shenzhen, a wealthy technology hub in southern China home to Tencent Holdings Ltd., shut down an electronics wholesale market this week. In the port city of Tianjin, schools pushed back their reopening after summer vacation as local authorities required more than 13 million residents to undergo mass testing after dozens of Covid cases were detected.

A total of 41 cities, which account for about a third of China’s GDP, are in the midst of outbreaks, the highest since April, according to research firm Capital Economics.

This Covid containment strategy also affected multinational companies, many of whom were forced into factory stoppages earlier in the year.

A recent survey of member companies by the U.S.-China Business Council found business confidence in China had fallen to the lowest since the business group began the poll more than 16 years ago, largely driven by Beijing’s continued use of abrupt Covid-19 lockdowns.

Unlike past slowdowns, when Chinese exports helped cushion a weaker economy, exports will provide less of a lifeline this time, economists said. Decades-high inflation and tightened monetary policy in the U.S. and other developed economies have crimped consumer spending, they said.

“I can’t think of any engine of growth going forward,” said Alicia García Herrero, chief economist for Asia Pacific at Natixis, who lowered her full-year China growth forecast to 3% from 3.5% this month.

Already, there are signs that global demand for Chinese goods is waning. A subindex tracking China’s new export orders contracted for the 16th month in a row in August, Wednesday’s data shows.

Even so, economists expect further disruption to factory operations to be limited, as temperatures have started to fall in China’s central Sichuan province. China’s state media said Wednesday that most of the power supply for industrial and commercial usage has been restored this week. The stimulus measures announced by Chinese policy makers last week, which include bank credit to launch infrastructure projects, should also support economic growth, they said.

Average home prices in dozens of cities have fallen since September last year and are showing no sign of recovery. Sales remain depressed by expectations that prices will keep dropping as well as fears that more cash-strapped developers could fail to complete construction of apartments.

Fresh weakness in property sales raises the risk that the prolonged property slowdown is now spilling over to the broader economy, hurting job growth and denting household consumption.

Robin Xing, chief China economist at Morgan Stanley, said in a note to clients last week he expected the property market to only “muddle through” the second half of this year.

“The housing market thus appears to remain locked between a ramp up in policy easing and the momentum of the downturn,” Mr. Xing said.