NBC’s “Tonight Show” still managed to prevail in the category that matters most to advertisers — Mr. Fallon had a 0.67 rating among adults under 50 years old, 40 percent better than CBS’s “Late Show,” which had a 0.48 rating. But the total viewer result is not merely symbolic. “The Tonight Show” had largely maintained an enormous lead over “The Late Show,” and this is the first time Mr. Colbert has posed a multiple-week challenge since he took over the show in September 2015. It is the second time in three weeks that “The Late Show” has virtually tied “The Tonight Show” in the ratings.

For the 2016-17 season, “The Tonight Show” has averaged 418,000 more viewers than “The Late Show.” But Mr. Colbert has narrowed the deficit. In the 2015-16 season, “The Tonight Show” averaged 3.6 million viewers, giving it an enormous lead of 877,000 viewers over “The Late Show.”

Mr. Colbert’s recent surge is intriguing, in light of the Trump presidency and given the host’s association with biting political commentary from his days on Comedy Central’s “Colbert Report.” For the week of Jan. 16, the week before the inauguration, Mr. Colbert came within 8,000 viewers of tying Mr. Fallon, the closest he had come to his NBC competitor since the week he came on the air. During the week of Jan. 23, Mr. Colbert was in repeats, which threatened to blunt his momentum, but it appears viewers tuned back in last week. Jimmy Kimmel’s ABC show is in third place in both total viewers and among adults under 50.

Mr. Colbert’s show has taken on a political charge in recent months, and it has only accelerated since Mr. Trump won the election. He has been openly critical of Mr. Trump, and last week Jon Stewart, Mr. Colbert’s old late-night partner on Comedy Central, appeared in a scathing segment.

Mr. Fallon, by contrast, has been criticized for being somewhat apolitical and appearing too cozy with Mr. Trump, especially in a September segment when he playfully tousled Mr. Trump’s hair.

Two weeks of data is a small sampling, and the ratings can reverse course at any moment, particularly if these frenetic opening weeks of the Trump presidency show any signs of dying down. Mr. Fallon has been a ratings juggernaut since he took over “The Tonight Show” three years ago, and his lead among 18- to 49-year-olds is no small matter.

But Mr. Colbert’s recent results are a welcome relief to CBS executives. It was only a year ago, after Mr. Colbert had failed to impress with his post-Super Bowl show, that there was concern among CBS executives that his show was adrift.

Since then, Mr. Colbert hired an executive producer, Chris Licht from CBS’s morning show, and hosted a series of live shows during the conventions and the presidential debates, where he began to find his stride — focusing on political humor and a presidency that seems made for it.

A version of this article appears in print on , on Page B3 of the New York edition with the headline: Political Bite Gives Colbert Ratings Edge Over Fallon. Order Reprints | Today’s Paper | Subscribe

The All-New DealBook

Our columnist Andrew Ross Sorkin and his Times colleagues help you make sense of major business and policy headlines — and the power-brokers who shape them.

Please verify you’re not a robot by clicking the box.

Invalid email address. Please re-enter.

You must select a newsletter to subscribe to.

* Required field

You agree to receive occasional updates and special offers for The New York Times products and services.