A judge has restored custody to the parents of an 11-year-old Canadian boy who underwent chemotherapy against his wishes.

Lawyers for the family and the Children's Aid Society agreed Tuesday that the boy, who has leukemia, can return home when he's released from the hospital instead of being placed in foster care.

The boy's father and stepmother lost custody to the CAS when they tried to refuse any further chemotherapy treatments, as the boy had requested.

But medical officials insisted that he needed the treatment and said the boy wasn't capable of making his own life and death decisions.

The agreement will see the CAS maintain the power to make medical decisions on the boy's behalf.