Several things have been credited with driving Stephen Colbert’s recent ratings surge: liberals craving a safe space, a backlash to his rival Jimmy Fallon’s hair tousle of Donald J. Trump, and Mr. Colbert simply being more comfortable as the host of his late-night show on CBS.

But when the September-to-May TV season ends on Wednesday night, Mr. Colbert will be the victor in total viewers over Mr. Fallon because of an unlikely reason: the DVR.

Mr. Colbert’s remarkable comeback is one of the biggest stories in TV, and it is the first time in 22 years that CBS will best NBC in the time slot other than 2010, when Conan O’Brien was removed from “The Tonight Show” in favor of a return to Jay Leno.

And though Mr. Colbert has been winning in total viewers on an almost nightly basis for some time — he’s had more total viewers than Mr. Fallon for 16 consecutive weeks — those victories alone would not have been enough to narrow the enormous deficit he faced over all just a few months ago.