If you use marijuana in a state that has legalized pot for medicinal purposes, Sen. John Walsh wants to make sure you don't lose your guns.

The Democratic senator from Montana, appointed earlier this year and facing a difficult race on Nov. 4, has filed an amendment to a spending package being considered on the Senate floor.

Walsh joins libertarian leaning Sen. Rand Paul in attaching a marijuana-related provision to the broad spending bill that includes funding for Commerce-Justice-Science, Transportation and Housing and Urban Development and Agriculture-FDA. But questions are arising over whether the Senate can complete work on the package because an agreement on amendments remains elusive.

Paul's legislation would prevent the Department of Justice from blocking states attempting to implement their own laws related to medical marijuana.

“The federal government cannot deny Montanans who rely on medical marijuana their Second Amendment rights,” Walsh said in a statement. “This measure will ensure that patients can hunt, purchase ammunition and protect their homes without fear of prosecution.”

The pro-gun amendment could appeal to the libertarian strain of thinking that runs through many western states. Walsh was named to replace Sen. Max Baucus when President Barack Obama named the Montanan to be his U.S. ambassador to China earlier this year. Walsh previously served as lieutenant governor and as the state’s adjutant general. Montana is one of the 22 states with comprehensive legalized medical marijuana programs.

Tom Angell, the chairman of Marijuana Majority, was pleased with both amendments, especially given Paul has presidential ambitions.

Pot policy unites "an interesting progressive-libertarian mix of strange political bedfellows," and "when you add in gun rights, we should see a very, very interesting bipartisan result," Angell said.A House committee this week opted against blocking D.C. from implementing a law to decriminalize possession of small amounts of marijuana. The decriminalization legislation, in the midst of a 60-day congressional review period, remains intact in the spending bill now headed for the full appropriations panel.Niels Lesniewski contributed to this report.