A federal judge ruled Friday that medical marijuana centers and dispensaries in Illinois can contribute to political committees and campaigns.

The decision came three and a half years after a state law banned those contributions.

In August 2013, Illinois became the 19th state in the country to allow for the use, growth and distribution of medical marijuana.

The same day, the Illinois General Assembly changed state election laws to prevent medical marijuana organizations or their political action committees from donating to campaigns or any political committees established to support a candidate.

The law also made it illegal for candidates or committees to accept money from medical marijuana organizations.

Will Illinois go for fiscal high by legalizing marijuana?

Claire Ball, who had run for comptroller on the Libertarian Party ticket, was one of two candidates from her party to challenge an Illinois law banning political donations by medical marijuana dispensaries. | Sun-Times file photo

This week’s decision by U.S. District Judge John Z. Lee found that law unconstitutional.

Judge Lee, of the Northern District of Illinois, ruled that the restriction was in violation of the First Amendment right to freedom of speech.

“Surely the First Amendment does not give the government free rein to selectively impose contribution restrictions in a manner that discriminates based on content or viewpoint,” Lee wrote in his decision.

The law was challenged in 2015 by two members of the Libertarian Party, who filed a lawsuit contending the regulations violated their freedom of speech and freedom of association.

Claire Ball, the Libertarian Party candidate for Illinois comptroller in 2016, and Scott Schluter, who ran for Illinois state representative for the 117th District, both plan to run for office again.

As Libertarian candidates supporting the legalization of marijuana, they said in their lawsuit that they wanted to solicit contributions from marijuana centers and dispensaries in the future.