China’s car sales snapped an 11-month streak of year-over-year growth as demand bolstered by a strong economic recovery collided with a global semiconductor shortage.

Sales of passenger cars in June were down 5.1% from a year earlier to 1.58 million vehicles, the China Passenger Car Association said Thursday. April-June sales were up 2.3% from the same period last year, when the market began to recover from a nationwide pandemic lockdown.

Much of the June decline could be attributed to supply constraints that have emerged in recent months, the association said. The historic chip shortage has crimped production for auto makers around the world, including some in China, the group said.

Japanese car makers were among the hardest-hit by the chip shortage last month. Nissan Motor Co. ’s China sales were down 16% in June from a month earlier, while Honda Motor Co. ’s were off 17%. Honda cited component shortages.

The car association said it expects supply constraints to ease in the second half of the year.

“The most severe moment has passed,” said Jenny Huang, corporate research director at Fitch Ratings, who expects chip supply to meet demand in 2022.

Ms. Huang said China-based car makers have mitigated the shortage’s effects by keeping sufficient inventories, ordering directly from chip makers and speeding up testing of domestically manufactured chips.

Bill Russo, founder of Automobility, a Shanghai-based consulting firm, said that the sales decline since the beginning of the year is a concerning sign for long-term demand. Chinese car sales returned to pre-pandemic levels in the first quarter of 2021 but have since slowed.

“There was some expectation or hope that the continued recovery would be there,” Mr. Russo said. “I don’t think we’re anywhere near that.”

Because of stringent virus-control measures, the Chinese economy recovered faster than other major auto markets, leading to an early rebound in demand. Iris Pang, chief economist at ING Bank, said that demand has been digested over the past 12 months; consumers interested in a new car have already bought it.

A global chip shortage is affecting how quickly we can drive a car off the lot or buy a new laptop. WSJ visits a fabrication plant in Singapore to see the complex process of chip making and how one manufacturer is trying to overcome the shortage. Photo: Edwin Cheng for The Wall Street Journal The Wall Street Journal Interactive Edition

June sales were also affected by recent Covid-19 outbreaks in southern China, the car association said, with rising cases prompting some consumers to stay home.

Electric vehicles continued to gain traction, accounting for a record share of China’s auto market in June. Sales of electric cars more than doubled from a year earlier to 223,000 vehicles, the association said, about 14% of overall sales.

Tesla Inc. sold 33,155 made-in-China vehicles in June, about 85% domestically. The rest were exported, the association’s data showed.

China’s U.S.-listed EV trio each reported record sales in June. XPeng Inc., which made its debut on Hong Kong’s stock exchange on Wednesday, delivered 6,565 cars, seven times as many as a year earlier. Domestic rival Li Auto Inc.’s deliveries more than quadrupled in June, and NIO Inc.’s doubled, to about 8,000 vehicles each.

The electric-vehicle industry’s gains have put it on track to reach Beijing’s goal of 20% of new-auto sales before the 2025 target date, analysts said, though Fitch Ratings’ Ms. Huang said future growth would require government subsidies and policies that encourage production and consumer purchases.

Write to Stephanie Yang at stephanie.yang@wsj.com