HELENA, Mont. — The Montana governor’s race has generated more broadcast television ads than all but one of the 12 states with gubernatorial elections this year, with Republican challenger Greg Gianforte responsible for the majority of them, according to data released Thursday.

Gianforte and Democratic Gov. Steve Bullock are in a close race with about a month to go until the Nov. 8 election. Recent campaign finance disclosures show ad spending is only ratcheting up in the final weeks as the candidates and outside groups vie for the attention of undecided voters and seek to motivate their supporters to go to the polls.

There have been 38,868 ads about the race broadcast on Montana televisions between January 2015 and Oct. 3, according to the new analysis by the Center for Public Integrity, a nonprofit investigative journalism organization based in Washington, D.C. That’s second to only the 64,756 ads that have aired in the Missouri governor’s race.

The Montana ads have come from four sources: Gianforte, Bullock, the Democratic Governors Association-funded Good Jobs Montana political action committee and the Republican Governors Association Right Direction PAC. The ads have cost a total of $5.7 million, and that total doesn’t include ads on cable television, radio or online.

Montana’s small population and television market means that candidates and PACs are getting a lot of airtime for their money. By comparison, candidates and third-party organizations in North Carolina have spent $19.4 million on nearly 36,000 ads — more than three times the cost for fewer ads in Montana.

Gianforte, a Bozeman entrepreneur who has sunk more than $3.1 million of his own money into his first run for office, has dwarfed the others in spending on ads. The $3.2 million his campaign has spent on ads represents 55 percent of the total, and his ads have aired more than 22,700 times on broadcast TV, according to the data.

Bullock’s campaign spent $894,060 on ads that ran 6,154 times, though his air time was boosted by the pro-Bullock Good Jobs, which spent more than $1.4 million on anti-Gianforte ads that ran 8,099 times.

RGA Right Direction spent $230,620 on anti-Bullock ads that have run 1,900 times.

Ted Dunlap, the longshot Libertarian Party candidate, has not spent any money on television ads, according to the data.

The Center for Public Integrity analyzed data about political advertising on broadcast television from Kantar Media/CMAG, a media tracking firm that monitors 211 media markets around the country and offers a widely accepted estimate of the money spent to air each spot.