A judge in Virginia Beach dismissed on jurisdictional grounds Tuesday a lawsuit that sought to deem two controversial books as obscene and to restrict their distribution to minors in libraries and bookstores.

Circuit Court Judge Pamela S. Baskervill tossed out the case against the books "Gender Queer: A Memoir" and "A Court of Mist and Fury," citing state law and the constitutional grounds of due process and free speech.

"Gender Queer" and "A Court of Mist and Fury" have stoked outrage from parents who object to the description or illustration of sexual acts in them. "Gender Queer," an award-winning 2014 graphic novel by Maia Kobabe, includes photos of sexual acts between a boy and a man.

"A Court of Mist and Fury," the suit alleged, "contains pages of extreme sexual conduct not suitable for children as young as 10 years old."

FAIRFAX COUNTY LIBRARY PUTS ‘GENDER QUEER’ AND ‘LAWN BOY’ NEXT TO BIBLE IN HOLIDAY ‘READING DISPLAY’

Gender Queer book with library photo in the background

Gender Queer Book (Fox News Digital)

State Del. Tim Anderson (R-Virginia Beach) filed the suit in April on behalf of Tommy Altman, a Virginia Beach tattoo shop owner and former Republican congressional candidate. The suit was based on a Virginia obscenity law that allows for books themselves to be sued and for judges to determine if the material is obscene or not. If a court deems the book obscene, bookstores face potential criminal penalties for selling them.

Baskervill, who had earlier found probable cause that the books could be considered obscene, wrote that Virginia law does not allow her the specific authority to determine if the books are obscene for minors.

Restricting distribution of the books would further authorize "prior restraint" of speech in violation of the First Amendment, the judge further argued. She also expressed concern regarding prosecution of booksellers who didn't realize they were selling books deemed by a court to be obscene.

"The illustrations in ‘Gender Queer’ are incredibly graphic and specific," Stacy Langton, founder of the Mama Grizzly movement, which aims to ensure that school libraries are free from pornographic and sexually explicit images and materials, told Fox News Digital. She confronted the Fairfax County School Board with images from the book last year.

"There's an image of pedophilia, which is a boy that is engaged in a sex act with an adult male," Langton added. "And then there are very X-rated images of other sexual acts that can't be broadcast on television. And even the words in ‘Gender Queer’ cannot be read aloud on any media or printed. So how is it not obscene?"

AMAZON ACCUSED OF 'ABSURD AND UNACCPETABLE' CENSORSHIP AFTER BOOK QUESTIONING TRANSGENDER MOVEMENT VANISHES

Author and publisher groups praised the judge's decision as a win for free speech.

Maria A. Pallante, president and CEO of the Association of American Publishers, described the ruling as an "unequivocal victory for the free speech rights of readers, authors, publishers, booksellers and libraries."

American Civil Liberties Union photo

In this photo illustration, the American Civil Liberties Union logo seen displayed on a smartphone. (Igor Golovniov/SOPA Images/LightRocket via Getty Images)

Eden Heilman, legal director for the American Civil Liberties Union of Virginia, told the Associated Press that "access to diverse perspectives is a huge part of our democracy, and any efforts to thwart that are really concerning."

CLICK HERE TO GET THE FOX NEWS APP

Tim Anderson, Altman's attorney, said he and his client would consider appealing the ruling to a higher court, and that he lawsuit "was never never about trying to ban gay literature or trans literature."

"This was simply just saying these (books) have really sexual explicit content and it’s not appropriate for kids," he said. He explained that the intention of the suit was to change a state law determining what is obscene for both children and adults, hoping to carve out a standard for what is deemed obscene, specifically for minors.

The Associated Press contributed to this report.