DENVER — For every five commercials Mitt Romney and his allies ran here in this vital swing state in the last two weeks of September, President Obama and Democrats ran seven, accusing Mr. Romney of having a “tough luck” attitude toward the middle class and asserting that Mr. Obama has brought the economy back from the brink.

In Florida, the disparity was greater. The number of pro-Obama ads outnumbered pro-Romney ads by almost 50 percent — some 13,000 of them accusing Mr. Romney of outsourcing jobs to China, trying to gut Medicare and hiding his tax returns from the public.

The story was the same in most of most of the other battlegrounds. In Ohio and in Iowa, in Norfolk, Va., and on the Boston stations that feed New Hampshire, Mr. Obama out-advertised his rival after the parties’ nominating conventions, according to data compiled by the political advertising monitoring firm Kantar Media/CMAG.

Mr. Obama’s continued advantage on the airwaves, which counters Democratic predictions that he would be far outgunned by Mr. Romney and his allied “super PACS” by now, may help explain why polls in most of the competitive states have shifted in his direction over the last month.