RICHMOND -- A federal judge has ruled that an art gallery's front-window painting of three nude men is not obscene and has barred the state of Virginia from prosecuting the gallery.

"This piece of artwork is not obscene," U.S. District Judge James R. Spencer said Wednesday after a four-hour hearing on the merits of the painting at the 1708 East Main Gallery.

Julyen Norman, the gallery's executive director, and Carlos Gutierrez-Solana, the artist, had filed a lawsuit to block city prosecutor Joseph D. Morrissey from bringing charges against the gallery.

"We're relieved and we're delighted," Norman said after the ruling. He said the window would be uncovered and that the exhibit would continue through July 8.

Gutierrez-Solana, a New York artist, said he was confident that his work would not be judged obscene. "It just feels real good to have a judge sit up there and vindicate that," he said. He said he hoped the ruling would send a message to judges and other government officials around the country who have been asked to decide whether artworks are obscene.

The plaintiffs said they reluctantly covered the nude painting in response to Morrissey's threats that he would prosecute. But the prosecutor said he merely discussed the work with the exhibit's cosponsor, the Arts Council of Richmond Inc., which then agreed to cover the window painting.

The window display, titled "In Memoriam," is a tribute to three of Gutierrez-Solana's friends who died of AIDS in April. The painting on the window glass shows three nude men in various stages of arousal with harsh quotes directed at AIDS victims printed nearby. The display also contains quotes that allude to the suffering of AIDS patients.

Gutierrez-Solana testified that the work was not intended to be erotic. "The piece is about intolerance," he said. "It's about grief. It's about rage."

Norman said the nonprofit gallery displays experimental works by young artists. He said the gallery gets about 30 percent of its funding from the state and federal governments.