A 74-year-old woman can sue a federal agent who held her for up to two hours, in urine-soaked pants, while he questioned her about a tiny piece of moon rock she has said her late husband received as a gift from astronaut Neil Armstrong, a federal appeals court ruled Thursday.

The agent who interrogated Joann Davis, as she stood in a restaurant parking lot, argued that his actions were justified because lunar material from the space program is government property that a private citizen cannot legally possess. But the Ninth U.S. Circuit Court of Appeals in San Francisco said Davis’ description of the events, if accurate, would show that her detention was “unreasonably prolonged and unnecessarily degrading.”

However, Davis’ lawsuit could still be derailed by a federal judge’s ruling last month that dismissed her separate claim against the federal government for false imprisonment.

Davis and her late husband, Robert Davis, worked at North American Rockwell under a National Aeronautics and Space Administration contract. After Robert Davis died in 1986, Joann Davis became sole owner of memorabilia he had received as an engineer on the Apollo project, including a paperweight containing a fragment of moon rock that she said Armstrong, the first human to walk on the moon, had given her husband in gratitude for his work.

In 2011, Davis encountered financial problems that included medical expenses for what proved to be her son’s fatal illness. She decided to sell the paperweight and a second one that is said to contain a small piece of the Apollo 11 heat shield, both of which she said Robert Davis had received from Armstrong. After getting no response from auction houses, she contacted NASA, which dispatched a team of agents headed by Norman Conley to meet her, the court said.

She and her second husband, Paul Cilley, met with Conley at a Denny’s restaurant in Lake Elsinore (Riverside County), with other plainclothes agents and sheriff’s deputies seated nearby. After Davis placed the paperweights on the table, Conley identified himself as a government agent, and another agent took the moon rock paperweight, the court said. Meanwhile, a sheriff’s deputy grabbed Cilley by the neck and bent his arm behind his back.

After reading Davis her rights, the court said, Conley took her to the parking lot for questioning that lasted between 90 minutes and two hours. She said later that she had told the officers she needed to use the restroom but was turned down before the interrogation.

But her version of events was rejected last month in a ruling by U.S. District Judge Consuelo Marshall of Los Angeles, who held a nonjury trial on Davis’ separate lawsuit against the government.

Marshall said she believed that Conley had offered to let Davis use the restroom, but she turned him down before agreeing to continue answering questions in the parking lot. Davis was released after questioning.

In a ruling that dismissed the suit against the government, Marshall said Davis had given “free and voluntary” consent to the agent’s questioning in the parking lot and was not in custody while being questioned. Conley and other agents were entitled to “confine” her in the lot while they questioned her, Marshall said.

Conley’s lawyer, John Rubiner, said Thursday that Marshall’s ruling should lead to dismissal of Davis’ suit against Conley. Davis’ lawyer, Peter Schlueter, disagreed, saying his client can sue for an abusive interrogation even if she was not in formal custody.

The appeals court, which heard the case before Marshall issued her ruling, said Thursday that Conley had no apparent law enforcement justification for “detaining Davis for two hours while she stood wearing urine-soaked pants ... in view of the public.”

Rather than informing Davis that her possession of the paperweight was illegal and asking her to turn them over, Conley “organized a sting operation involving six armed officers to forcibly seize a Lucite paperweight containing a moon rock the size of a rice grain from an elderly grandmother,” Chief Judge Sidney Thomas said in the 3-0 ruling.

Bob Egelko is a San Francisco Chronicle staff writer. Email: begelko@sfchronicle.com Twitter: @egelko