Bernie Sanders is defending his record on guns. (AP Photo/Troy Wayrynen)

Bernie Sanders's critics say he supports stricter rules on guns only when it's convenient. For his part, the Democratic presidential candidate insists that he is a reliable ally of gun-control advocates.

"I've been strong on this issue," he said in an interview with CNN's Jake Tapper on Sunday, citing his votes in favor of background checks at gun shows and a ban on sales of semi-automatic weapons.

Sanders did take those votes, as well as many others in favor of stricter gun control. Over his long career, though, he's also stood against gun control on several crucial pieces of legislation, as this voting history compiled by the Tampa Bay Times shows. Sanders did not discuss those votes in Sunday's television interview.

Sanders said he voted for instant background checks, which he called "probably the most important thing we can do." Yet many gun-control advocates favor longer waiting periods to instant background checks to allow for the authorities to more thoroughly vet someone who is trying to buy a weapon. Current law requires the Federal Bureau of Investigation to approve or deny a gun purchase within three days. Dylann Roof, accused of killing nine people at a church in Charleston, S.C. in July, was able to buy a gun because it took the feds more than three days -- the legal maximum -- to determine whether he was eligible.

During the debate over the Brady handgun bill, which established the background-check system, Sanders did vote in favor of instant background checks on an amendment. Ultimately, though, he voted against the Brady legislation, which imposed a five-day waiting period. Former aides told the Times that Sanders's aim was to represent Vermont, a sparsely populated state where many people own guns for hunting. Sanders's constituents there did not want a waiting period for gun purchases, they said.

Gun-control advocates were also frustrated when Sanders voted for a 2005 bill to bar victims of gun violence from suing firearms manufacturers. Although legal experts say that such lawsuits would have been unlikely to succeed in most cases, since the manufacturers could argue that a third party was responsible, the bill still gave the industry a level of legal protection unique among makers of dangerous consumer products.

And a year later, Sanders voted to make it harder for the Bureau of Alcohol, Tobacco, Firearms and Explosives to identify and shut down unscrupulous gun dealers. While data on the black market for guns is limited, an investigation by The Washington Post, among other studies, has found that most guns used in crimes come from just a few gun stores -- about 1 percent of licensed dealers. The bureau lacks the resources and the legal authority to prevent those dealers from doing business.

On Sunday, Sanders said that the way to reduce gun violence is to improve the country's mental health system. While it is true that the mentally ill are more violent on average than the general population, there aren't many people who are mentally ill, and only a small fraction of overall violence can be blamed on mental disorders, psychologists say.

"If we were able to magically cure schizophrenia, bipolar disorder and major depression, that would be wonderful, but overall violence would go down by only about 4 percent," Duke University's Jeffrey Swanson told ProPublica last year.