"Our disciplined approach to the U.S. market, combined with strength in China and further growth of GM Financial, drove a very strong quarter," said GM CFO Dhivya Suryadevara. "We will continue to take actions to mitigate headwinds including foreign currency volatility and commodity costs."

GM swung to a profit during the quarter from last year's loss, which stemmed from the company's sale of its European business to Groupe PSA. GM's net income was $2.5 billion, or $1.75 a share, compared with a loss of $2.98 billion, or $2.03 a share, a year ago. It generated $35.79 billion in revenue, up 6 percent from $33.62 billion during the same quarter last year. Analysts had expected the company to generate $34.85 billion during the third quarter.

The carmaker's shares jumped by 6.3 percent in morning trading. During the premarket, it had gained 10 percent.

Here's what the company reported compared with what Wall Street was expecting, based on a survey of analysts by Refinitiv:

General Motors said Wednesday it sold fewer vehicles during the third quarter — but at higher prices — helping the Detroit automaker deliver a better-than-expected earnings report that sent its shares soaring.

Suryadevara said on a conference call that GM expects fourth quarter performance to be strong, with solid sales of highly profitable crew-cab trucks.

The company said it sold fewer cars but was able to raise its prices in the U.S. by an average of about $800 per vehicle to more than $36,000, setting a record for transaction prices and about $4,000 over the industry average. It also said Cadillac sales in China broke a record, up 4 percent over the previous year and 20 percent year to date.

GM's third-quarter vehicle sales volume dropped by 14.7 percent from the previous year, the company said. Sales fell across every region and every brand, with Cadillac seeing the smallest decline in sales among its marquee brands, 3.9 percent, from the previous year.

Sales of several Chevrolet and GMC truck models, including the Silverado LTZ and High Country and the GMC Sierra SLT, Denali and its new off-road AT4 crewcab models exceeded expectations, GM said. The automaker expects to ship about 120,000 of the new trucks in the second half of 2018.

The strength of GM's truck and SUV business in North America is further evidence of how important that market is to all three major U.S. automakers, who have been less successful abroad.

"North America is the best place to do business," said CFRA analyst Garrett Nelson. "Looking at international operations, it is just a matter of who can tread water the best."

Major automakers have been reporting higher material costs and other increased expenses stemming from the trade war, particularly between the United States and China.

That's been punctuated by signs of weak demand for new cars overall, particularly in North America. A recent estimate from industry tracker LMC Automotive said North American new vehicle sales are expected to fall in October from last year and face further pressure.

"Affordability may be the canary in the coal mine for the level of auto sales as we close out 2018 and begin to look at 2019. Transaction prices are still edging higher," said Jeff Schuster, president, Americas operations and global vehicle forecasts at LMC Automotive.

The Federal Reserve is expected to raise interest rates again in December, followed by three more rate hikes in 2019, he said. Drivers are buying more used cars, in the meantime.

"This is a combination that could cause consumers to be squeezed out of the new-vehicle market, putting pressure on volume even if other fundamentals are favorable," Schuster said.

GM's shares have fallen nearly 19 percent since the beginning of the year.