Some of the Bay State’s most prominent anti-pot pols are rolling in the green, taking thousands of dollars in donations from deep-pocketed marijuana companies seeking political leverage in the state’s budding multimillion-dollar industry.

The willingness of top elected officials — Gov. Charlie Baker, Boston Mayor Martin J. Walsh and House Speaker Robert A. DeLeo — to quietly accept political donations while publicly decrying legalized pot has shocked longtime cannabis opponents.

“It runs against everything they believe in,” said Jody Hensley, a policy adviser for the anti-weed Massachusetts Prevention Alliance. “I think this is carelessness in their campaign office. I just don’t believe that they would accept this knowingly,” Hensley added.

Baker and Lt. Gov. Karyn Polito have pocketed $4,500 in the past two years from marijuana industry companies such as Happy Valley, Alternative Therapies Group and Garden Remedies, according to state campaign finance records.

DeLeo took in $1,750, while Walsh accepted $1,000, according to state records.

The bipartisan power trio vowed to fight legalized marijuana in 2016, creating the Campaign for a Safe and Healthy Massachusetts in 2016, a political opposition group that spent $2.8 million to oppose recreational sales. They argued that making the drug more accessible could further increase the state’s opiate addiction toll.

“You’ll hear the other side say that marijuana is not a gateway drug,” said Walsh during a 2016 press conference. “If you know anyone in the recovery community … you’ll hear that most of them, many of them started with marijuana.”

Baker cautioned about “the creation of a billion-dollar, for-profit commercial marijuana industry,” at the time.

But when reached yesterday, the Baker campaign appeared unfazed by suggestions of hypocrisy and defended the donations.

“Gov. Baker and Lt. Gov. Polito are proud to have broad, bipartisan support for their approach to governing and reaching across the aisle to serve the people of Massachusetts, working with the Legislature, educators, law enforcement and strong public health advocates like the governor’s Cannabis Control Commission appointee Jennifer Flanagan, to responsibly and safely implement the adult use of marijuana and honor the will of the voters,” said Terry MacCormack, a spokesman for the Baker and Polito campaign.

A Walsh representative had no immediate comment, asking for more time to review the campaign’s public filings, which are submitted to the Office of Campaign and Political Finance regularly by all elected officeholders.

The DeLeo campaign did not respond to requests for comment.

Jim Borghesani, spokesman for the Question 4 campaign that legalized pot, said of the donations, “This is a logical progression of normalization that cannabis companies are mirroring other industries in political contributions, even if, in this case, the contributions flow to prior legalization opponents. Whether or not these politicians show some actual leadership regarding the voters’ legalization decision remains to be seen.”

Despite the concerns of top pols — about the dangers of gateway drug use, stoned driving and other enforcement issues — Bay State voters legalized recreational marijuana sales on Nov. 8, 2016, and lawmakers spent over six months developing regulations and creating the state’s Cannabis Control Commission. The five-member-board is still reviewing and granting licenses to grow and sell marijuana before the first pot shop can open. Law enforcement agencies meanwhile are trying to find ways to determine how stoned a driver is, and sounding alarms about the illegal pot trade, with police chiefs saying drug dealers use pot’s legal status as a cover for illegal activity.

The marijuana-based political donations come as cities and towns prepare for the first pot shops to open and Beacon Hill becomes increasingly flooded by marijuana lobbyists. Companies like Weedmaps, Good Chemistry Inc., Weston Roots Management and others reported paying $435,000 this year to lobbying companies, according to state records.

Hensley, meanwhile, argued that taking even small donations sends the wrong message.

“Politicians should not risk the perception of their support for this new addiction-for-profit industry,” she said.