By Trefor Moss

SHANGHAI--Auto sales in China increased 10.4% in the second quarter year over year, as dealers and auto makers began to repair the damage from a first quarter wrecked by the coronavirus.

The government-backed China Association of Automobile Manufacturers said Friday that the industry had bounced back more strongly than expected, posting its first quarterly gain in two years. June sales of 2.3 million, up 11.6% year over year, were a record for the month, according to the association.

Sales were down 16.9% year over year in the first six months of 2020, however, setting the China market on course for its third straight year of declines despite the recent rally. This year's auto sales will be 10% to 20% down compared with 2019's 25.8 million vehicles, the association forecasts, with the pandemic limiting the sector's comeback.

"The uncertainty of the international epidemic still exists," said Chen Shihua, the association's deputy secretary-general. "This will affect consumption."

With car markets still in a state of collapse in the U.S. and Europe, China has emerged as a relatively bright spot for global manufacturers seeking to steady their operations after the shock of the pandemic.

The China market is itself still in recovery mode, however. The recent uptick measured by the manufacturers association relates to the wholesale business and points to dealerships restocking with new models. But retail sales are still sluggish. They declined 3.4% year over year in the April-to-June period, according to the China Passenger Car Association, a separate industry body that tracks dealers' sales to consumers.

This situation should flip in the third quarter, most analysts predict: The wholesale business looks set to fall again, with dealerships having already rebuilt their inventories, but retail sales should gather pace as consumers are coaxed back into the marketplace by generous discounts.

That is likely to squeeze margins as the industry tries to drum up business by whatever means necessary. "The risk of a price war is rising as market shares and volume targets are prioritized over profitability," said Jing Yang, director of corporate research at Fitch Ratings.

Ford Motor Co. said its second-quarter sales increased 3% to 158,589--the first increase for the company in China in three years. General Motors Co.'s quarterly China sales declined 5.3% year over year to 713,600.

Toyota Motor Corp. said its China sales increased 23% year over year in June. A surge in second-quarter sales left the Japanese auto maker down only 2.2% year over year in the first half, despite the coronavirus slump. In contrast, Ford and GM were down 10% and 25% in the first half, respectively.

After several months of deep discounting designed to get the market moving again, car dealers expect the rest of 2020 to be a grind, even if volumes improve.

"People are saving money. It's a very painful process," said Zhang Huai, a SAIC Motor Corp. dealer from Hefei in eastern China. "I don't hold out much hope for the second half of the year."

After losing around $700 a vehicle as it cleared out leftover stock, Mr. Zhang's dealership is offering discounts of roughly $300 on new models, plus other perks. But demand is still weak, he said, as government coupons dished out to stimulate consumption have had little impact.

Mao Limin, a dealer for BYD Co. and Toyota in the southern city of Shenzhen, says some potential customers who do have funds are investing them in stocks or real estate--with both assets producing good returns in recent months--and that has hurt sales.

Mao Limin, a dealer for BYD Co. and Toyota in the southern city of Shenzhen, says some potential customers who do have funds are investing them in stocks or real estate--with both assets producing good returns in recent months--and that has hurt sales.

"The situation is getting better, but it's barely enough to keep the business running," Ms. Mao said.

Meanwhile, the slump in electric-vehicle sales in China continued through the second quarter: EV sales fell 37% year over year in the first half of 2020 to 393,000, after also declining in 2019. EV sales will fall to around one million this year, according to the China Automotive Technology and Research Center, a government agency, down from 1.2 million last year.

But the center expects the country's EV ambitions to get back on track with 1.6 million sales next year, as global auto makers launch more electric models.

While most of China's EV makers are struggling, Tesla Inc. sold over 46,000 locally built Model 3 sedans in the first six months of the year, according to the passenger-car association, making the Model 3 China's bestselling EV this year by a substantial margin.

Raffaele Huang and Yin Yijun contributed to this article.

Write to Trefor Moss at Trefor.Moss@wsj.com