John Hinckley was 25 he when shot and wounded President Ronald Reagan outside a hotel in Northwest Washington. Here's how Hinckley's release from a mental institution will work. (Claritza Jimenez/The Washington Post)

Thirty-five years after he shot President Ronald Reagan and three others outside a D.C. hotel, John W. Hinckley Jr. will be released from a government psychiatric hospital, a federal judge ordered Wednesday.

The ruling ends the institutionalization of the one of the nation’s most notorious mental health patients.

Outrage over Hinckley’s acquittal in the 1981 shooting reshaped the insanity defense in courts across the country. The revelation that he had pulled the trigger to impress a movie star added obsession and celebrity to the case. And extraordinary television footage of the attack on the 40th U.S. president brought the event to millions of American homes.

In Wednesday’s court order, U.S. District Judge Paul L. Friedman wrote that Hinckley, 61, no longer poses a danger to himself or others and will be freed to live full time with his mother in Williamsburg, Va. His release could come as early as Aug. 5 and is subject to dozens of conditions, some of which could be phased out after a year if Hinckley adheres to them.

“Mr. Hinckley has received the maximum benefits possible in the inpatient setting,” Friedman wrote in a 103-page opinion. “The court finds by the preponderance of the evidence that Mr. Hinckley will not be a danger to himself or to others if released on full-time convalescent leave to Williamsburg under the conditions proposed.” The 14-page order also said Hinckley could be returned to St. Elizabeths Hospital in the District if he relapses or violates the terms of his release

Friedman cited Hinckley’s successful completion of more than 80 visits over the past decade to Williamsburg. What began as supervised trips with family in the 1990s gradually were extended with court permission so that Hinckley now spends up to 17 days a month at the home of his 90-year-old mother in a gated golf course development.

The release order says Hinckley must stay within a 50-mile radius of Williamsburg and requires him to carry a trackable phone and provide information about vehicles he will be driving. It also bars him from tampering with his computer’s Web browser history, uploading any content to the Internet or accessing social media without unanimous approval of his treatment team.

Hinckley also must continue weekly contact with therapists in Williamsburg, return at least monthly for outpatient treatment in Washington and volunteer or work three times a week. He must stay out of contact with the news media, his victims and their families, the U.S. president, and members of Congress.

Hinckley was 25 when he wounded Reagan, White House press secretary James Brady, U.S. Secret Service agent Tim McCarthy and D.C. police officer Thomas Delahanty with six exploding “Devastator” bullets from a .22-caliber pistol. All survived the attack, but Brady was left paralyzed by a shot to his head and spent years before his death in 2014 advocating for gun control.

Hinckley said he shot Reagan to try to impress actress Jodie Foster after repeatedly viewing the film “Taxi Driver.”

Foster, through a spokesman, declined to comment on Wednesday’s ruling

After an eight-week trial, a federal jury in Washington found Hinckley not guilty by reason of insanity in June 1982 of all 13 counts against him, setting off a sharp public backlash. The federal government and 38 states subsequently rewrote laws to raise the standard of proof required for the insanity defense, which is now rarely used and is even more rarely successful.

Some research has found that defendants successfully raise an insanity defense in 1 of 500 felony cases nationwide and that of that small pool, defendants are freed between 5 and 65 percent of the time depending on the jurisdiction, making Hinckley’s release all the more exceptional.

People whose lives were directly affected by the shooting had mixed reactions to Hinckley’s pending release

While Reagan’s eldest son, Michael Reagan, said that he and his father forgave Hinckley, Patti Davis continued to view her father’s would-be assassin harshly. Hinckley successfully waited out and wore down the justice system, Davis said. “I’m not surprised by this latest development, but my heart is sickened,” she said.

In a statement, the Ronald Reagan Presidential Foundation and Institute, which hosts Reagan’s presidential library, said, “Contrary to the judge’s decision, we believe John Hinckley is still a threat to others, and we strongly oppose his release.”

The shooting left Brady paralyzed and prompted him and his wife to battle to expand background checks for gun sales. Dan Gross, president of the Brady Campaign to Prevent Gun Violence, said Hinckley’s release would “only redouble our resolve.” The Bradys “refused to be victims or give in to anger or injury,” he said.

Reagan died at 93 in 2004, a decade after he was diagnosed with Alzheimer’s disease.

Medical examiners ruled Brady’s death a homicide resulting from the wound in the shooting. Prosecutors declined to bring new charges against Hinckley, citing legal barriers, including that a jury had previously reached a verdict in his case.

Now a police chief in Orland Park, Ill., McCarthy, the Secret Service agent shot in 1981, said that in his view, Hinckley “murdered one man, almost killed the president of the United States and shot two others. They better be right about what they are doing” in releasing him.

Hinckley and his family remain under court order not to speak with reporters, but his longtime defense attorney Barry Wm. Levine said the judge’s finding “should give great comfort to a concerned citizenry that the mental health system and the judicial system worked and worked well.”

“Mr. Hinckley recognizes that what he did was horrific. But it’s crucial to understand that what he did was not an act of evil. It was an act caused by mental illness,” Levine said. “He is profoundly sorry, and he wishes he could take back that day, but he can’t.”

Bill Miller, a spokesman for U.S. Attorney Channing D. Phillips in Washington, said the office was reviewing the judge’s opinion and had no comment.

The Secret Service, which monitored Hinckley’s movements on more than 200 occasions in 2013 and 2014, according to information presented in court last year, referred questions to the U.S attorney’s office.

Former Secret Service agent Arnette Heintze, who was in charge of the Chicago office, said the long list of restrictions put in place by the judge would provide a level of comfort to his former colleagues because the measures continue a high level of coordination and communication with the people in Hinckley’s life.

But Dan Bongino, a former Secret Service agent who served on two presidential details, said Hinckley’s release will put a significant burden on the agency to track him any time a president travels near Williamsburg.

“Just because he hasn’t acted up in a clinical environment in decades doesn’t mean he does not have a proclivity to act out violently when he’s out of that setting,” Bongino said. “There is no room for error on this.”

In the order, Friedman, who took over the case in 2001, approved the hospital officials’ recommendation to release Hinckley, including 34 conditions that incorporated tighter monitoring that prosecutors had sought.

The conditions ban Hinckley from having weapons and alcohol and require him to give his treatment team and the Secret Service access to his online and email accounts.

At the government’s request, Hinckley — who plays the guitar, paints and has expressed an interest in photography — is also barred from performing in public and from exhibiting or publishing any material without approval.

“The notoriety-fame issue is one that is part of [Hinckley’s] pathology,” government psychiatric expert Raymond F. Patterson testified during hearings in spring last year before Friedman, warning also of Hinckley’s troubling “sense of entitlement and a disregard for the rules.”

The judge noted that in other ways, Hinckley’s return to society and independent living has gone well.

Hinckley’s mother and siblings, Scott B. Hinckley and Diane Hinckley Sims, have pledged full support, the judge wrote, and Hinckley’s relationships with women — a historic concern — have grown healthier.

Hinckley, who has spent time volunteering at a local mental hospital, has been offered a job at a church and has taken his mother to dine out and for scenic drives, according to court filings.

“Mr. Hinckley has gone bowling, attended several lectures, attended outdoor musical concerts, and joined a local community center to exercise and take classes offered,” Friedman wrote, adding that Hinckley “also has made significant strides toward developing friendships in the community and displayed improved self-initiative.”

Reaction to Hinckley’s upcoming move was met warily by neighbors in the Kingsmill community where his mother lives.

Rick Johnson, a 13-year resident whose parents knew Hinckley’s parents, was welcoming but acknowledged that he might be in the minority. “They played bridge together and said they were lovely people,” Johnson said.

Hinckley, he said, “has put in his time. Why not give him what’s left of his life?”

About a half-mile from Hinckley’s mother’s home, neighbor Joe A. Mann disagreed. Mann said neighbors think highly of Hinckley’s mother, but Mann plans to mobilize friends and local networks to stay alert.

“I don’t know one single person who says, ‘Yeah, bring him on.’ ”

Jane Elizabeth in Williamsburg and Jennifer Jenkins contributed to this report.