Alex Scott, 45, who has cerebral palsy, was moved to a nursing home Saturday after 38 days at Inova Loudoun Hospital in Leesburg, Va. (Katherine Frey/The Washington Post)

After being stranded for more than a month at a hospital, a ­45-year-old man with cerebral palsy went to a nursing home Saturday and could, per a judge’s order, eventually return to the ­less-restrictive group home where he had lived for more than two decades.

At an emergency hearing Friday night, a Loudoun County judge denied a request from Alex Scott’s family to immediately send him back his Northern Virginia group home but also ordered that the group home take steps in the next two weeks toward accepting Scott back into its care.

The decision was seen as a partial victory for Scott’s family in a standoff over a feeding tube that has captured the attention of disability rights advocates and an online community that has followed Scott’s plight.

“While we are disappointed Alex is not going home today, we are encouraged that Loudoun County has been ordered by the court to take specific measures to make sure Alex goes home as soon as possible,” Scott’s sister Samantha Tunador said late Friday.

On Saturday, Scott, who cannot speak, had spent 38 days in the hospital while his family and caregivers at Kentwell Group Home argued over what is best for him.

‘Heartbreaking’: Medical standoff leaves man with cerebral palsy stranded at hospital

Scott’s relatives said the group home, where he lived for more than two decades, told them it would not take him back without a feeding tube. His family has maintained that the medical procedure is unnecessary and would benefit Kentwell employees more than Scott.

Scott cannot feed himself, has difficulty swallowing and can take as long as 30 minutes to eat, according to a complaint filed by the family’s attorney, John Whitbeck, in Loudoun Circuit Court. But cerebral palsy is not a progressive disease, and the severity of his needs has remained the same the entire time he has lived at Kentwell Group Home, the complaint says.

Scott had “excellent care” and was “very happy” at the group home until 2014, when his longtime caregiver retired and a new caregiver took over, according to the complaint.

“Now Alex faces leaving the only home he has known for 23 years because Kentwell personnel do not wish to continue to give him the same care he has had for the entire 23-year period,” the complaint reads. It also says his physicians “have opined that a feeding tube is not only unnecessary, it would be dangerous for Alex as his stomach and intestines are abnormally located in his abdomen.”

The hearing came after Medi­caid denied further funding for Scott’s hospital stay, and he was set to be discharged. His family expects his stay will be temporary at the nursing home, one that the complaint described as “more restrictive and unnecessarily intensive in care.”

Loudoun County Attorney Leo Rogers said Saturday that privacy laws limit what he can say about the case. But he said the steps the county will take in the next few weeks were proposed at the hearing by Margaret Graham, the director of Loudoun’s Department of Mental Health, Substance Abuse and Developmental Services, which oversees the group home. They include training the group home staff on how to care for Scott.

“It has been our intention from the beginning to get him to a point where he can be at the group home, and the group home staff are prepared to handle his needs as a patient,” Rogers said.

“We’re going to make sure his safety and care is paramount,” he said. “The physical location is not as critical as his safety.”

Virginia woman with Down syndrome seeks power to live the way she wants

Scott’s relatives want him to return to the group home, they said, because he has formed relationships there and that is the home he knows.

“It is clear that the judge agreed that sending Alex home was the best thing for him, and her ruling showed thoughtful consideration of how to do that,” Whitbeck, the family’s attorney, said Saturday. “If the county does not follow through on the requirements of the ruling, the judge has cleared the way for us to take this case back into court on an emergency basis, and we most certainly will.”

Scott was admitted to Inova Loudoun Hospital on March 31 for having low oxygen levels, according to the complaint. ­Tunador, his sister, said that she and her parents expected that he would be discharged after a few days.

When it became clear that the group home was not planning to take him back, Tunador turned to social media to catalogue Scott’s hospital stay, using the hashtag #TakeAlexHome.

“Day 11,” Tunador wrote on Facebook on April 10. “I promise you Alex, we are doing everything we can to get you out of the hospital and back to your home.”

“Day 20,” she declared in a video. “We really are not much further.”

“Day 37,” she wrote Friday, “please keep sharing and sending emails. We have not been heard yet.”

Hours later, she learned of the judge’s decision.