Democratic presidential hopeful Bernie Sanders (I-Vt.), center. (Andrew Caballero-Reynolds/AFP/Getty Images)

Sen. Bernie Sanders (I-Vt.) defended himself against an attack ad from allies of former Maryland governor Martin O'Malley (D) in an interview broadcast Sunday, saying he has a "strong record" on gun control.

"I cast what I think was a pretty brave vote banning assault weapons, doing away with the gun show loophole and fighting for instant background checks so that we make sure that guns do not fall in the hands of those people who should not have it," the presidential hopeful said on ABC's "This Week With George Stephanopoulos."

O'Malley and Sanders are vying to be seen as the chief alternative to Hillary Rodham Clinton in the Democratic presidential primary. A pro-O'Malley super PAC has sought to draw attention to Sanders's record on guns in an attack ad, saying the Vermont senator is "no progressive when it comes to guns."

Sanders said he comes from a state where gun rights are important to people, and he underscored the importance of a "national dialogue" to bridge the gap between those who disagree sharply in the debate over gun laws.

"One thing we can't have, we can't have people demagoguing against folks just because they go out and hunt and they own guns," he said. "On the other hand, rural America has got to understand that guns in Vermont are not the same thing as guns in Chicago, where they're used to kill kids or shoot at police officers."