The Oregon Court of Appeals on Wednesday threw out the misdemeanor conviction of a man caught peeing next to a building in downtown Portland, saying he was prosecuted under a frequently used state law that shouldn't apply to public urination.

The ruling could have a sweeping effect by preventing district attorney's offices across the state from using Oregon's "offensive littering" law to charge people who urinate in public spaces.

It appears people now can legally relieve themselves where they want -- unless they step foot into the city limits of municipalities that outlaw public urination with their own local ordinances. Portland has several laws that could apply but they weren't used in the case reviewed by the Appeals Court.

Public urination is a widespread livability issue no matter the size of the city. In 2016, Newport police put out a warning on Facebook, reminding people: "It is illegal to empty your bladder in an area that is not specifically designated for such activity." The post suggests that people "invest in adult diapers" if they don't think they can abide by the rules.

In 2011, the Portland Water Bureau drained 7.8 million gallons from a Mount Tabor reservoir after a 21-year-old man urinated into it.

Wednesday's ruling was based on an appeal by 36-year-old Ryan Charles Corcilius, who had just pulled into downtown Portland after driving up from California in 2015 as part of a cross-country road trip, according to the Appeals Court summary of the case.

“By the time he got to Portland and parked, it was already an 'emergency' for him to use a restroom,” the Appeals Court wrote.

Corcilius asked a gas station attendant to use the bathroom but was told it wasn’t open to the public. He then went into a Subway sandwich shop and was told the restroom was for paying customers only and he'd have to wait in a long line to make a purchase first, the summary states.

“He began to panic because of the intense pressure of having to urinate,” the Appeals Court wrote. “He found a spot that he believed was secluded and urinated on the side of a building.”

A private security guard hired by local businesses to enforce livability laws spotted Corcilius and called police, who cited Corcilius for misdemeanor offensive littering.

Corcilius couldn't be reached for comment for this story.

Defense attorney Joseph DeBin argued that Corcilius couldn’t be convicted of offensive littering because it outlaws “discarding or depositing any rubbish, trash, garbage, debris or other refuse” on public property or other people’s properties, but it doesn’t specifically outlaw urine. Legislators would have written “urine” into the law if they had wanted to include it, DeBin said.

Multnomah County Circuit Judge Stephen Bushong disagreed and declined to dismiss the case before trial. A jury found Corcilius guilty.

The Appeals Court reversed his conviction. In a majority opinion, the court wrote that urine isn’t specifically mentioned in the state’s offensive littering law. What’s more, it’s not "discarded" or "deposited" from the body, the ruling said.

“One discharges urine, rather than discarding it,” it said.

Brent Weisberg, a spokesman for the Multnomah County District Attorney's Office, said his office knows of no other state law they could use to prosecute urinating in public.

The Legislature could take action to expand the offensive littering law by adding that it applies to public urination.

In a survey of the state's larger cities, many have ordinances that prohibit public urination to some extent -- including Portland, Gresham, Beaverton, Lake Oswego, Bend, Eugene and Salem. Many don’t criminalize the act, but do impose fines.

Under Portland city code, people who urinate in public could conceivably be prosecuted for misdemeanor indecent exposure -- if members of the opposite sex could see their genitalia at the time.

Otherwise, city code forbids urinating in any park or “pedestrian plaza” -- punishable with a fine but no criminal conviction. But it’s unclear if a “pedestrian plaza” covers all sidewalks, parking lots and other areas visible to the public within the city.

A three-judge panel made the appeals ruling. Judges Darleen Ortega and David Schuman formed the majority and Judge Erika Hadlock dissented. Read the majority and dissenting opinions here.

-- Aimee Green