Foreign automakers have dominated China’s car market for decades, selling millions of vehicles and raking in enormous profits. That golden era is now coming to an abrupt end.

The rapid rise of China’s homegrown electric vehicle (EV) makers, such as BYD and Xpeng (XPEV), is upending the largest passenger car market on the planet and leaving the world’s biggest carmakers on the losing end.

The latest sign of the steep challenges facing traditional automakers came Monday, when Volkswagen warned it could close plants in Germany for the first time in its history, in an effort to cut costs.

The German car giant has seen its deliveries in China, its single largest market, tumble by more than a quarter from just three years ago to 1.34 million in the first half of this year. And last year, the company lost its crown as China’s biggest-selling car brand to BYD, sheddinga title it had held since at least 2000.

But Volkswagen, the world’s second-largest carmaker after Toyota ™, is not the only company in trouble. Ford (F) and General Motors (GM) are also among firms seeing sales and market share vanish in China as local consumers spurn overseas brands to buy Chinese instead.

In July, foreign carmakers’ share of auto sales in China slipped to 33% from 53% in the same month two years earlier, according to data from the China Passenger Car Association (CPCA).