Washington (CNN) -- Missouri's tight restrictions on protests and picketing outside military funerals were tossed out by a federal judge Monday, over free speech concerns.

A small Kansas church had brought suit over its claimed right to loudly march outside the burials and memorial services of those killed in overseas conflicts. The state legislature had passed a law to keep members of the Topeka-based Westboro Baptist Church from demonstrating within 300 feet of such private services.

Church members, led by pastor Fred Phelps, believe God is punishing the United States for "the sin of homosexuality" through events including soldiers' deaths. Members have traveled the country, shouting at grieving family members at funerals and displaying such signs as "Thank God for Dead Soldiers," "God Blew Up the Troops" and "AIDS Cures Fags."

The Supreme Court last year had granted a temporary injunction blocking enforcement of the law until it could be challenged. The justices will hear a similar challenge this fall involving the same church.

Judge Fernando Gaitan in a 19-page order, dismissed the state legislation.

The laws, said the Kansas City-based judge, "could have the effect of criminalizing speech the mourners want to hear, including speech from counter-protesters to plaintiffs' [the Westboro Church's] message. As the law burdens substantially more speech than is necessary to further the government's interest, [the law] violates the free speech clause of the First Amendment."

Phelps, his daughter, Shirley Phelps-Roper, and other church members had protested near the August 2005 funeral of Army Spc. Edward Lee Myers in St. Joseph, Missouri. The married Army Airborne Ranger died while on patrol in Samarra, Iraq, when an improvised explosive device detonated near his Humvee military vehicle. He was 21, and in addition to his wife, he left behind a daughter. He was later buried at Leavenworth National Cemetery in Kansas.

In response to that protest, Missouri lawmakers passed the "Spc. Edward Lee Myers Law," criminalizing picketing "in front or about" a funeral location or procession.

Phelps-Roper then went to federal court to ask for a preliminary injunction to block enforcement of the statute until its constitutionality could be reviewed. A federal appeals court eventually agreed. That court did not address the broader First Amendment claims, but noted the law was overly intrusive, since it "restricts expressive activity not just within or on the premises of a cemetery of a church, but also on traditional public fora such as the adjacent public streets and sidewalks."

The Supreme Court has never addressed the specific issues of laws designed to protect the "sanctity and dignity of memorial and funeral services," as well as the privacy of family and friends of the deceased. But the justices in October will hear an appeal from the father of a U.S. solider killed in Iraq, after members of the Westboro Church conducted an angry demonstration at his son's burial service in Maryland. The family of the Marine had won a $5 million judgment from the protesters, which was overturned by lower federal courts.

At issue is a balancing test between the privacy rights of grieving families and the free-speech rights of demonstrators, however disturbing and provocative their message. Several other states besides Missouri have attempted to impose specific limits on when and where the church members can protest.

The justices are being asked to address how far states can go to justify picket-free zones and the use of "floating buffers" to silence or restrict the speech or movements of demonstrators exercising their constitutional rights in a funeral setting. Various jurisdictions across the nation have responded to the protests with varying levels of control over the church protesters.

According to a legal brief it filed with the Supreme Court, church members believe it is their duty to protest and picket at certain events, including funerals, to promote their religious message: "That God's promise of love and heaven for those who obey him in this life is counterbalanced by God's wrath and hell for those who do not obey him."

The congregation is made up mostly of Phelps and his family. The pastor has 13 children, and at least 54 grandchildren and seven great-grandchildren. He described himself as an "old-time" gospel preacher in a CNN interview in 2006, saying, "You can't preach the Bible without preaching the hatred of God."

The church has also protested at least since 1993 at funerals of gay persons, those who died from AIDS, and others whose lifestyles are deemed sinful but were touted as heroic upon their death.

Missouri officials said the appeals court improperly balanced the free speech rights of both sides in favor of the church.

"Mourners cannot avoid a message that targets funerals without forgoing their right to partake in funeral or burial services, so are appropriately viewed as a captive audience" that is simply unable to shut out the offensive message, said state attorneys.

The case is Phelps-Roper v. Koster (06-4156-cv).