OAKLAND, Calif. — A judge Friday ordered a California hospital to keep an Oakland girl who had been declared brain dead on life support. She was declared dead after what was supposed to have been a routine tonsillectomy.

The ruling by Superior Court Judge Evelio Grillo came as the girl’s family and Children’s Hospital Oakland officials agreed to get together and choose a neurologist to further examine Jahi McMath, 13, and determine her condition. The judge scheduled a hearing Monday to appoint a physician.

The girl’s family sought the court order to keep McMath on a ventilator to help her breathe while another medical opinion is sought. The judge also ordered that the hospital continue giving the girl IV fluids.

The family says doctors at Children’s Hospital Oakland wanted to disconnect life support after doctors declared the girl brain dead Dec. 12.

After her daughter underwent a supposedly routine tonsillectomy and was moved to a recovery room, Nailah Winkfield began to fear something was going wrong.

Her daughter was sitting up in bed, her hospital gown bloody, and holding a pink cup full of blood.

“Is this normal?” Winkfield said she repeatedly asked nurses.

Despite hospital employees’ efforts to help her, McMath kept bleeding profusely, then went into cardiac arrest, her mother said.

Hospital officials said they couldn’t discuss the case because the family hasn’t given them permission to do so.

In an interview at Children’s Hospital Oakland late Thursday, Winkfield described what happened after her daughter had tonsil-removal surgery to help with her sleep apnea.

She said that even before the surgery, her daughter had expressed fears she wouldn’t wake up after the operation. To everyone’s relief, she appeared alert, was talking and even ate a Popsicle afterward.

But about a half-hour later, she began bleeding from her mouth and nose despite efforts by hospital staff and her family.

Family members said there were containers of McMath’s blood in the room, and hospital staff members were providing transfusions to counteract the blood loss.

“I don’t know what a tonsillectomy is supposed to look like after you have it, but that blood was un-normal for anything,” Winkfield said.

Relatives said hospital officials told them in a meeting Thursday that they want to take the girl off life support quickly.

“I just looked at the doctor to his face and I told him you better not touch her,” Winkfield said.

The family filed a request Friday for a temporary-restraining order prohibiting the hospital from taking McMath off life support or any other current treatment.

At the hearing later, the hospital’s attorney, Doug Straus, said two doctors unaffiliated with the hospital examined McMath and concluded she was brain dead. But he said, “We’re happy to cooperate with the judge’s suggestion that an independent expert be provided to confirm yet again that brain death is the outcome that has occurred here.”

The family’s attorney, Christopher Dolan, said the family wanted independent tests.

Hospitals do a barrage of tests to determine brain death, said Dr. Cristobal Barrios, an associate professor and a trauma and critical-care surgeon at the University of California, Irvine. He is not involved in McMath’s care and spoke about general hospital protocols.

The tests include touching a patient’s cornea to elicit a blink, moving a breathing tube to stimulate a gag reflex, tickling the back of the throat to bring on a cough, and applying pressure or pain.

If the patient fails to respond to all of those tests, doctors remove the breathing tube for a few minutes. If there is any brain activity, the patient should begin breathing within a few minutes, he said.

In some cases, doctors will also draw a blood sample, add radioactive tags and re-inject it into the body to track where it flows. If the blood doesn’t flow to the brain, Barrios said, there is no brain activity.

Generally, two teams of specialists must run the tests and determine independently that the patient is brain dead, he said. At UC, Irvine, those evaluations must take place 12 hours apart if the patient is a child.