WASHINGTON — The Supreme Court on Monday allowed a challenge to an Ohio law banning lies in political campaigns to move forward, turned back a challenge to a law concerning gun purchases and refused to hear a case about holding high school graduations in churches.

The court ruled unanimously that two advocacy groups could challenge an Ohio law that makes it a crime to make knowingly or recklessly false statements about political candidates that are intended to help elect or defeat them. The first offense could lead to six months in jail and the second could lead to disenfranchisement.

Lower courts had dismissed the case, saying the groups seeking the challenge had not faced imminent harm sufficient to give them standing to sue. Justice Clarence Thomas, writing for the court, said the groups “have alleged a credible threat of enforcement” of the law and so were not barred from pursuing their challenge to it.

The case was brought by Susan B. Anthony List, an anti-abortion group, and Coalition Opposed to Additional Spending and Taxes.