Shares of General Motors (GM 4.37%) surged to as much as $45 back in June, after the company announced a $2.25 billion investment in its GM Cruise autonomous vehicle unit by technology powerhouse SoftBank. The deal valued the loss-making Cruise unit at $11.5 billion (roughly $8 per GM share), making the rest of General Motors seem even cheaper.

However, this euphoria wore off very quickly. The main catalysts were GM's second-quarter earnings report, which included a reduction of the company's 2018 earnings-per-share guidance, and a recent slowdown in the Chinese auto market. The net result was that by the third week of October, GM stock had fallen 30% from its June high.

GM Chart

General Motors Stock Performance, data by YCharts.

Despite these headwinds, the General reported impressive third-quarter results on Wednesday. It also hinted that its updated forecast may have been too conservative. GM stock surged 9% in response -- and there could be plenty more upside over the next few years.

A massive earnings beat

In early October, GM reported that vehicle deliveries fell sharply in its top two markets -- the U.S. and China -- last quarter. Deliveries plunged 11% in the U.S. and 15% in China. Incentive spending did decline in the U.S., but investors still feared the worst. On average, analysts expected EPS to slip to $1.25 from $1.32 a year earlier.

Instead, General Motors reported blowout results, with adjusted EPS surging more than 40% to $1.87. Some of the improvement came from a lower tax rate, but GM's operating profit (which excludes taxes) increased 25% thanks to margin expansion.

One big reason for GM's strong margin performance was that its wholesale volume (which determines revenue and profit) increased slightly, even as deliveries to customers declined.

A white 2019 Chevy Silverado truck.

A 2019 Chevy Silverado. Image source: General Motors.

In North America, which accounts for the bulk of GM's profit, wholesales jumped 11% last quarter to around 843,000. Higher volume and lower incentive spending more than offset rising commodity costs, driving nearly 2 percentage points of operating margin expansion and a 37% jump in operating profit. While the sharp divergence between wholesales and deliveries may seem concerning, U.S. dealer inventories still ended the period down nearly 3% year over year.

Wholesale volume did decline in China -- but only by 4%. Moreover, most of the market weakness was in smaller cities, where GM's sales mix skews toward cheaper and less profitable models. As a result, GM's equity income in China rose 6% to $485 million -- a new record for Q3.

Lastly, GM Financial benefited from strong consumer credit trends and higher used-vehicle auction values. Segment profit came in around $500 million for a third consecutive quarter, up more than 60% year over year.

The future looks bright

In conjunction with its strong earnings report, GM said that it now expects its full-year EPS to be at the high end of its updated $5.80-to-$6.20 guidance range -- and possibly even higher. Looking ahead, the General has a good chance to grow its earnings and cash flow in 2019 and 2020.

The recent launch of a new generation of full-size pickup trucks is the biggest near-term catalyst. The new models should command substantially higher prices, and General Motors has increased its manufacturing capacity for more lucrative crew-cab configurations. The rejuvenation of the Cadillac brand -- a new model will arrive every six months through 2020 -- should also help. Outside the U.S., cost cuts and the introduction of a new low-cost vehicle platform could drive a substantial improvement in profitability.

GM is also nearing the peak of a recent investment cycle. Capex should moderate starting next year, and GM Financial will be able to return virtually all of its profit to the parent company by 2020, driving a big improvement in free cash flow.

Considering that GM stock still trades for just six times earnings -- and less than five times earnings excluding its Cruise subsidiary -- the potential upside for patient investors is enormous.