In a swift end to a long legal battle, a brain-dead California toddler died Thursday after being taken off life support.

A Los Angeles Superior Court judge made the surprise ruling to dissolve the restraining order keeping Israel Stinson on life support.

Stinson's mother, Jonee Fonseca, told the Sacramento Bee from the child's bedside at Children's Hospital Los Angeles that the ventilator was turned off at 3 p.m. and the 2-year-old from Vacaville died almost immediately after.

"He's gone," Fonseca told the newspaper in a tearful phone call.

The court last week had granted a temporary restraining order keeping the child on the ventilator while the family brought in another neurologist.

"It was a complete shock," Alexandra Snyder, one of the mother's attorneys, said of the Thursday decision. "A complete turnaround from last week."

The hospital filed an appeal that was heard Thursday morning, and the judge said that because the case had already been heard in state and federal court the restraining order was dissolved.

The child has passed through several hospitals and his case has passed through several courts since he was declared brain dead at University of California, Davis Medical Center after cardiac arrest following an apparent asthma attack in April.

The life-support fight was similar to the battle over Jahi McMath — a 13-year-old girl who underwent a tonsillectomy and tissue removal at Children's Hospital in Oakland, California, to treat sleep apnea. The girl suffered massive bleeding, had a heart attack and was declared brain dead in 2013. But her family fought to keep her on life support and moved her to New Jersey, which requires medical treatment of patients like McMath who are declared dead but show minimal brain function.