An ailing 9-month-old boy whose mother sneaked him out of a hospital to prevent doctors from performing court-ordered surgery may live with his father until permanent custody is decided, a judge ruled Thursday.

Riley Rogers had the surgery last week and was expected to leave the hospital Friday.

The boy's mother, Tina Carlsen, was charged with second-degree domestic-violence kidnapping after she took Riley from the hospital on June 22 by hiding him inside a diaper bag. Carlsen wanted to seek natural treatments for the child's poorly functioning kidneys, but the judge sided with doctors who insisted the boy needed surgery to prepare for dialysis.

After the child disappeared, authorities issued an Amber Alert and spent two days searching for the pair. They were found about 50 miles south of Seattle.

The case has put the boy and his mother at the center of a legal battle testing the rights of parents and the roles of doctors and judges in disputes over children's medical treatment.

The boy's father, Todd Rogers, said both parents will continue to press doctors to consider alternative treatments. He did not endorse Carlsen's removal of the child from the hospital but said he understood why she took such drastic action.

"Any mother would respond the way Tina did," Rogers said.

The custody agreement requires Rogers to cooperate with doctors at Children's Hospital and Medical Center in Seattle. Carlsen will be granted supervised visits with the boy.

Carlsen, 34, pleaded not guilty to the criminal charges last week. She is free on bail while awaiting trial.