Former New York mayor Michael Bloomberg’s PAC spent almost $200,000 on a losing effort to oust the Milwaukee County sheriff. (Jonathan Ernst/Reuters)

Gun control advocates seeking to assert their political power suffered a big loss Tuesday in Wisconsin when Milwaukee County Sheriff David Clarke (D) narrowly bested a fellow Democrat to win his party’s nomination for a second term.

The normally sleepy race attracted huge amounts of outside spending, including almost $200,000 from Independence USA PAC, the super PAC funded by former New York City mayor Michael Bloomberg, and $350,000 from a Wisconsin progressive group that spent big against Gov. Scott Walker (R) in the 2012 recall election.

Bloomberg’s group and the Greater Wisconsin Committee both dropped cash on late advertisements against Clarke and in favor of his rival, Milwaukee police officer Chris Moews (D). They, and most of the Milwaukee Democratic establishment, objected to Clarke’s unabashedly pro-gun stance.

Clarke is known for his controversial comments, including a radio advertisement in which he urged county residents to take a firearm safety course rather than calling 911. In another radio ad, Clarke called guns “a great equalizer.” After the Newtown shootings in 2012, Clarke called for arming teachers in schools.

Milwaukee County Executive Chris Abele (D), Mayor Tom Barrett (D) and Police Chief Edward Flynn all criticized the advertisements, which were paid for with taxpayer money. The local Democratic Party endorsed Moews.

Clarke got support from the National Rifle Association, whose members know him well: He spoke at the NRA’s annual meeting in Indianapolis this year, our colleagues at The Volokh Conspiracy reported. Former governor Tommy Thompson (R) also campaigned for Clarke, targeting moderate Democrats.

With 100 percent of precincts reporting Tuesday night, Clarke beat Moews by about 4,500 votes out of 113,000 cast, 52 percent to 48 percent. Absentee votes have yet to be counted, but it’s unlikely Moews will be able to overcome the deficit. The Associated Press called the race for Clarke.

Clarke was first appointed sheriff by Gov. Scott McCallum (R) in 2002. He won election in 2002, 2006 and 2010, when he beat Moews in the Democratic primary by a similarly narrow 53 percent to 47 percent margin.

The race was the first major contest in which Bloomberg’s group has weighed in this year. The PAC said it planned to spend about $10 million in the 2012 elections, and it spent more than $1 million on behalf of Virginia Gov. Terry McAuliffe (D) in 2013. The group also spent more than $2 million to influence a special election in Illinois for then-state Rep. Robin Kelly (D), who replaced U.S. Rep. Jesse Jackson Jr. (D) in 2013.