An ex-Alaska Airlines pilot accused of trying to cut the engines of a passenger flight while off-duty and riding in an extra seat in the cockpit was released from jail pending trial Thursday, after an Oregon judge approved it with conditions that include keeping away from aircraft.

Multnomah County Circuit Court Judge Thomas Ryan made the decision as Joseph Emerson pleaded not guilty to reduced charges of reckless endangerment; he previously faced attempted murder charges.

Emerson, of Pleasant Hill, California, has also pleaded not guilty to a federal charge of interfering with a flight crew. The judge in that case also agreed that he could be released pending trial.

Emerson was released from jail around 5 p.m. He and his wife, Sarah Stretch, shared a tearful embrace as he walked out. He declined to comment. Noah Horst, his lawyer, said the couple planned to drive home to California.

The release conditions include that Emerson undergo mental health services, stay away from drugs and alcohol, and not come within 30 feet (9 meters) of an operable aircraft. His bail was set at $50,000 and he had to post 10% of that, or $5,000, to be released, Horst said.

Emerson’s wife said she was happy her husband was coming home. Speaking to reporters through tears after the arraignment, she also said she was glad that the case has raised awareness about pilot mental health.

“I’m saddened that this situation had to happen to my husband and to the people it affected. But I know that this has created a movement and momentum to help thousands of other pilots,” Stretch said.

Horst said Emerson did not fully possess his mental faculties when he was on the Horizon Air flight and did not consciously choose to put people at risk.

“Is he criminally responsible? No. Does he need help? Yes,” Horst told reporters. “Does Mr. Emerson deserve to be home today with his family and surrounded by his friends? Yes, he does.”

Emerson is accused of trying to cut the engines of a Horizon Air flight from Everett, Washington, to San Francisco on Oct. 22 while riding in the cockpit as an off-duty pilot.

He was subdued by the flight crew and the plane was diverted to Portland, Oregon, where it landed safely with more than 80 people on board.

According to charging documents, Emerson told Port of Portland police following his arrest that he had been struggling with depression, that a friend had recently died and that he had taken psychedelic mushrooms about 48 hours before he attempted to cut the engines. He also said he had not slept in more than 40 hours, according to the document.

The averted disaster renewed attention on cockpit safety and the mental fitness of those allowed in them.