Shares of CarMax (KMX 0.54%) rallied as much as 13% early Thursday, then settled to close up 5.2% after the used-vehicle retailer announced better-than-expected quarterly earnings. CarMax also resumed its share repurchase program.

CarMax's soaring profitability

On one hand, for its fiscal third quarter ended Nov. 30, Carmax's revenue declined 5.5% year over year to $6.15 billion, technically missing analysts' consensus estimates for sales of $6.3 billion. On the other hand, CarMax's net earnings more than doubled on a year-over-year basis to $82 million, or $0.52 per share, trouncing Wall Street's estimates for earnings of $0.41 per share.

Carmax has strived in recent quarters to maximize its profitability by reducing SG&A (sales, general, and administrative) expenses, improving its credit mix within the CarMax Auto Finance (CAF) division, and maintaining a strong gross profit per vehicle sold.

"Our third-quarter performance reflects the continued efforts of the team that have resulted in several quarters of sequential improvements across key components of our business, despite the persistent widespread pressures in the used-car industry," stated CarMax CEO Bill Nash.

CarMax enjoyed particular strength on the wholesale side of its business. Wholesale units increased 7.7% year over year with an average gross profit per unit remaining steady at $961. Retail used-unit sales declined 2.9%, while retail gross profit was also in line with the same year-ago period at $2,277.

What's next for CarMax stock?

CarMax also resumed its share repurchase program in Q3 after pausing it a year ago. The company bought back 648,500 shares of common stock during the quarter for $41.9 million. That leaves it with $2.41 billion remaining available under the current repurchase authorization -- a hefty sum, considering CarMax's entire market capitalization stands at "just" $12.5 billion, as of this writing.

CarMax didn't provide specific forward revenue or earnings guidance. But given its relative earnings beat, encouraging business trends, and massive repurchase authorization, it's hardly surprising to see shares rallying today in response.