Cadillac vehicles are displayed at General Motors' luxury brand headquarters in New York on Oct. 4. (Spencer Platt/Getty Images)

Despite signs of decline in the auto market, General Motors is flourishing.

On Wednesday the automaker reported a 25 percent jump in income for the third quarter, compared with 2017, boosted by higher-priced domestic truck and SUV sales in North America and China. GM’s income came in at a record $3.2 billion. The company’s earnings far surpassed expectations, coming in at $1.87 adjusted earnings per share, compared with $1.25 predicted by analysts.

GM stock jumped more than nine percent Wednesday, to close at $36.59 a share.

“Our third-quarter performance demonstrates our determination to manage risks and deliver strong business results while continuing to advance the future of mobility,” chief executive Mary Barra said in a news release.

Since 2009, global car sales have surged an average of five percent a year, Fortune recently reported. But last year showed signs of the first sustained slowdown since the global financial crisis, with U.S. auto sales falling about one percent in 2017, according to Kelley Blue Book. Continued declines of new car purchases have troubled auto companies, especially as they grapple with technology that may reshape the industry and brace for the impact of the Trump administration’s trade dispute.

When President Trump announced tariffs last summer, Detroit’s Big Three automakers — GM, Ford and Fiat Chrysler — all trimmed their profit forecasts for the rest of the year, citing the rising commodity costs that would lead to hikes in prices and manufacturing costs. GM took a hard stance, warning of the fallout within the auto industry and saying that the tariffs risked “undermining GM’s competitiveness against foreign auto producers by erecting broad brush trade barriers that increase our global costs” in comments filed with the Commerce Department in June.

But GM has largely managed to dodge the quagmires of trade and manufacturing that have hurt some of its competitors. And despite drops in sales in the United States, down 11 percent, and China, down 15 percent, GM still performed well in those key markets, thanks to better sales of higher-end cars. This quarter reaped $35.8 billion in revenue for the company, up six percent from last year, despite an overall slowdown in new car purchases, especially in North America.

“GM earnings were stellar against the backdrop of rising head winds,” said Michelle Krebs, an analyst with Autotrader. “I think it speaks to the discipline of their business. They’re being very careful about costs and expenses and keeping inventory in line with demand.”

GM’s domestic sales hinged on a new line of higher-priced trucks and crossovers, such as the Chevrolet Silverado and the GMC Denali, with U.S. profit rising 37 percent, to $2.8 billion. In China, the world’s largest auto market, GM’s income hit a record high amid challenges in the Chinese economy because of the trade war and a whopping 40 percent tax on imported vehicles. GM’s success in China this quarter was driven by record sales in Cadillacs and strong Chevrolet deliveries. In a conference call with investors Wednesday, Barra said the company has plans to sustain its success in China, despite the drop in demand for new cars.

“We have a very good launch cadence of products that are getting a very strong reception from consumers,” Barra said. “We’re seeing very good growth in Chevrolet and very good growth in Cadillac. There are no negative views about our brands over there.”

At home, GM is seeking to cut costs with buyouts that could affect as many as 18,000 employees, Dow Jones reported Wednesday. GM did not immediately respond to a request for comment about the buyouts. Earlier this month, Ford also announced a major buyout as the company undergoes a $25 billion restructuring effort.

The buyout is proof that GM is bracing for industry turbulence, Krebs said. “It’s not surprising,” she said. “We anticipated this because we’re expecting that U.S. sales will soften again next year. … They’re preparing for a possible downturn.”

Meanwhile, GM is set on evolving to hang onto its status as an industry powerhouse. In July, the company announced its peer-to-peer car-sharing program, which lets Chevrolet, Buick, GMC and Cadillac owners put their cars and trucks up for rent when they aren’t using them. In early October, Honda announced it would be working with Cruise Automation, GM’s self-driving car subsidiary, to develop a self-driving car. Cruise Automation is now valued at $14.6 billion. Cars from that partnership are being tested in San Francisco and could hit American streets as early as 2019, Barra said during the call.

“Launching in one city is just one step in what will be a multiyear … transformation in how people move from point A to point B,” Barra said.

The company is also betting on the growth of electronic vehicles, which are predicted to make up 65 percent of new light-vehicle sales by 2050, according to the Energy Policy Simulator. GM has several electric vehicles planned for debut in the next few years. The company is working to break down barriers for the average driver, Barra said, focusing on cost reduction and improving charging methods. GM’s auto parts subsidiary, ACDelco, is working to develop fast-charging options.

“We believe in an all-electric future,” Barra said. “We’re focused on making electric vehicles that are affordable, attainable, drivable and have the right range.”