NEW YORK, NOV. 12 -- A state judge ruled today that Joyce Brown, the first person hospitalized under Mayor Edward I. Koch's new policy of taking mentally ill people off the streets, is "rational, logical, coherent" and free to return to her life on a hot-air vent on Second Avenue.

But city officials won a temporary stay of the decision late today, sending Brown back to the $600-a-night psychiatric unit at Bellevue Hospital where 21 other homeless people are being detained.

Brown, a 40-year-old former secretary from New Jersey, had captivated a court hearing at Bellevue with lucid, witty testimony about her life as a "professional" street person. She said she occasionally tears up money and curses people who try to help her because she resents having dollars tossed at her when she has panhandled enough for the day.

"I've heard people say, 'Take it, it will make me feel good' . . . . Is it my job to make them feel good by taking their money?" Brown asked.

The ruling by Acting Manhattan Supreme Court Justice Robert D. Lippmann is a setback for Koch's policy of having city workers round up homeless people deemed a danger to themselves or others.

Koch assailed today's decision, saying, "If anything happens to that woman, God forbid, the blood of that woman is on that judge's hands. The program goes on."

City workers singled out Brown as a test case after Koch spoke with her and several other homeless people during a tour of the streets last May.

The battle over Brown, who calls herself "Billie Boggs" after local television personality Bill Boggs, dramatizes the difficulty in gauging the mental health of people who choose to live on the streets.

In his ruling, Lippmann said Brown was articulate and displayed "a sense of humor, pride, a fierce independence of spirit, quick mental reflexes." While "her mode of existence does not conform to conventional standards," he said, "she copes, she is fit, she survives.

"She refuses to be housed in a shelter. That may reveal more about conditions in shelters than about Joyce Brown's mental state. It might, in fact, prove she's quite sane," Lippmann said.

The judge noted that Brown, by panhandling about $7 a day, bought a daily meal of milk, juice, chicken cutlets and ice cream. He also observed that psychiatrists were unable to agree on Brown's condition, with some calling her a paranoid schizophrenic and others saying she is rational and coherent.

One of Brown's four sisters said today that her family still believes Brown is "hostile and belligerent" and should be institutionalized. But Robert Levy, an attorney for the New York Civil Liberties Union, hailed the decision.

"The only evidence the city had {against Brown} is that she goes to the bathroom on the streets," Levy said. "I see that in New York City every day, because there's a lack of public restroom facilities."

Dr. Luis Marcos, vice president of the city's Health and Hospitals Corp., contended that Brown's "self-neglect" was "so severe" that she had to be helped against her will. He said Brown's lucid testimony did not conflict with his diagnosis of schizophrenia.

"You speak to someone who is paranoid, and they are usually very bright, they speak very coherently," Marcos said. "But it has a severe impact on the judgment of the person. Someone may think they are Jesus Christ or that they can fly."

Brown, described by city officials as "dirty, disheveled and malodorous," said she defecated in the streets because East Side restaurants would not let her use their bathrooms.

According to her sisters, Brown comes from a middle-class family in Livingston, N.J., and held several jobs after graduating from high school and business school, most recently as a secretary for a state human rights commission.

But Brown used cocaine and heroin for several years, lost her job in 1985 and lived on and off with family members before being asked to leave. She was convicted of assault, was later expelled from a Newark shelter and then spent several weeks in a New Jersey hospital, where she was diagnosed as psychotic.

The diagnosis was disputed by Dr. Robert E. Gould, a Manhattan psychiatrist who testified on Brown's behalf. "Her judgment is not great, but there's no law that says people can't live on the streets," he said. "The only time she gets angry is when these do-gooders try to force treatment on her."

The new 28-bed unit at Bellevue will soon be full. Earlier this week, another judge ruled that the city properly had hospitalized a 64-year-old homeless woman who believed she was being poisoned by plutonium and radium in the water.

Health experts have warned that the Koch policy could overwhelm the city's public hospitals, where the mentally ill already wait for days in emergency rooms. But Marcos said state officials have agreed to transfer new homeless patients to a Queens psychiatric hospital.

At the court hearing, Brown described her life on a hot-air vent outside an ice-cream parlor. "You can either handle it or you can't," she said. "You have to be experienced . . . . I'm a professional."