Two state representatives want to turn Massachusetts into a sanctuary state for marijuana, filing legislation that would prohibit state and local police from participating in federal cases against people or licensed operators who follow state cannabis laws.

“We have a state law, it’s valid, and we think it should be respected,’’ said state Representative Dave Rogers, who filed the bill Friday, along with fellow Democrat Mike Connolly. “If federal law enforcement has something different in mind, they can use their own resources, because Massachusetts taxpayers shouldn’t have to pay to do something that goes against our laws.’’

The bill is a response to the decision earlier this month by Attorney General Jeff Sessions to end the US government’s hands-off marijuana policy and give federal prosecutors discretion to enforce the federal prohibition on the drug, even against state-licensed cannabis operations. Rogers called the shift in policy “retrograde and mindless,’’ noting that public opinion has swung heavily in favor of legalization.