It started out as a routine operation to treat an increasingly common medical problem, childhood sleep apnea. It became an anguished fight over the fate of a 13-year-old girl who, although pronounced legally dead by medical doctors, remains alive in the opinion of her parents.

The girl, Jahi McMath, was declared brain dead after complications from surgery Dec. 9 at Children’s Hospital Oakland, which wanted to remove her from a ventilator that has kept her breathing so her heart continues to pump. But her family protested in court and she has remained connected to the machine.

On Friday, amid acrimonious battles in three courts, an Alameda County Superior Court judge mediated an agreement between the hospital and the family. Late Sunday, Jahi was moved from the hospital to an undisclosed location. She was still attached to a ventilator.

“It was a very tense situation,” said Christopher Dolan, the family’s attorney. “Everybody played by the rules.”

Under the agreement, Jahi was released to the Alameda County coroner’s office, a move that officially classified the girl as dead. The coroner’s office then handed the “body” over to the family. The coroner’s office issued a death certificate for Jahi — listing the date of death as Dec. 12 — but did not pronounce a cause of death.

“It is hard for a mother to receive a death certificate for a child who has a heart beating,” Mr. Dolan said. “It’s an awkward situation.

It is hard for a mother to receive a death certificate for a child who has a heart beating

“We don’t think she’s dead. She’s not passed. Her heart beats. Her kidneys function. She regulates her body temperature. … She should not be treated as a dead person.”

However, in documents filed in court Friday, Dr. Heidi Flori, the director of the Children’s Hospital’s pediatric intensive care unit, said such movements by a brain-dead person were not uncommon and were caused by spinal and muscular reflexes. They were not indications that the person was alive.

AP Photo/Courtesy of McMath Family and Omari Sealey, FileJahi McMath

Three doctors have declared the girl brain dead based on exams and tests showing no blood flow or electrical activity in either her cerebrum or the brain stem that controls breathing.

On Sunday, Jahi was moved by private ambulance by a critical care team while attached to a ventilator but without a feeding tube.

Mr. Dolan wouldn’t specify where the girl was taken but he said “they are going to care for her, respect her and love her. And they’re going to call her Jahi, not ‘the body.'”

Nailah Winkfield, the girl’s mother and a Baptist, said last week, “I believe in God and I believe that if he wanted her dead, he would have taken her already. Her heart is beating; her blood is flowing. She moves when I go near her and talk to her. That’s not a dead person.”

The hospital has argued since before Christmas that Jahi’s brain death means she is legally dead and she should be disconnected from the ventilator. It has refused to fit her with a feeding tube or a breathing tube that would help stabilize her during a move, saying it was unethical to perform medical procedures on a dead person.

A court injunction prohibiting the Children’s Hospital from removing the ventilator that has kept Jahi’s heart pumping since her surgery expires at 5 p.m. Tuesday.

Jahi was admitted to Children’s Hospital last month and underwent three surgical procedures that included removing her tonsils and adenoids. She subsequently “suffered serious complications” that resulted in her death, according to court documents submitted by the hospital.

The hospital sought to remove the ventilator but the family objected, asserting that the heartbeat was proof that she remained alive. In a document filed in federal court, the family’s lawyer stated that the girl’s parents were “Christians with firm religious beliefs that as long as the heart is beating, Jahi is alive.”

Multiple outside doctors and bioethicists observing the case have confirmed that a patient in Jahi’s condition meets the legal criteria for death and has no chance of recovering.

Mr. Dolan said that an outpatient clinic in New York that treats people with traumatic brain injuries has expressed willingness to care for Jahi. He asked for privacy for the caregivers because the issue has raised such strong emotions.

“It’s brought out the best in people and the worst in people,” he said. “We’ve had people make threats from around the country. It’s sad people act that way, so for Jahi’s safety and for those around her, we will not be saying where she went or where she is.”

Dr. David Durand, the hospital’s chief of pediatrics, said, “Our hearts go out to the family as they grieve for this sad situation and we wish them closure and peace.”

OAKLAND, Calif. — An Oakland family whose 13-year-old daughter has been declared brain dead is hoping to celebrate Christmas in the hospital with her after a judge ordered hospital officials to keep her connected to a breathing machine.

AP Photo/Courtesy of McMath Family and Omari Sealey, FileJahi McMath

Jahi McMath was declared brain dead after experiencing complications following a tonsillectomy at Children’s Hospital in Oakland.

As her family sat stone-faced in the front row of the courtroom, an Alameda County judge on Monday called for Jahi to be independently examined by Paul Graham Fisher, the chief of child neurology at Stanford University School of Medicine. The judge also ordered the hospital to keep Jahi on a ventilator until Dec. 30, or until further order from the court.

The examination was conducted on Monday and may possibly continue Tuesday.

Hospital staff and Fisher will conduct an electroencephalogram, or EEG, and tests to see if blood is still flowing to Jahi’s brain.

On Dec. 12, doctors concluded the girl was brain dead and since then have wanted to remove her from life support. Jahi’s family wants to keep her hooked up to a respirator and eventually have her moved to another facility.

The family said it believes she is still alive and that the hospital should not remove her from the ventilator without its permission.

“It’s wrong for someone who made mistakes on your child to just call the coroner … and not respect the family’s feeling or rights,” Sandra Chatman, Jahi’s grandmother and a registered nurse, said in the hallway outside the courtroom.

“I know Jahi suffered, and it tears me up.”

The family’s attorney also asked Judge Evelio Grillo to allow a third evaluation by Paul Byrne, a pediatric professor at the University of Toledo. The hospital’s attorney objected to Byrne, saying he is not a pediatric neurologist.

‘It’s wrong for someone who made mistakes on your child to just call the coroner’

The judge is expected to consider the request to use Byrne, and another hearing was scheduled for Tuesday morning.

Byrne is the co-editor of the 2001 book Beyond Brain Death, which presents a variety of arguments against using brain-based criteria for declaring a person dead.

In a phone interview, Byrne said he could not comment in detail because he had not seen any of Jahi’s medical records. But the fact that her ventilator is still functioning properly is a sign that she is alive, he said.

“The ventilator won’t work on a corpse,” he said. “In a corpse, the ventilator pushes the air in, but it won’t come out. Just the living person pushes the air out.”

Jahi’s family says the girl bled profusely after a tonsillectomy and then went into cardiac arrest before being declared brain dead.

Outside the courtroom, Dr. David Durand, chief of pediatrics at Children’s, said staff have the “deepest sympathy” for the family, but that Jahi is brain dead.

“The ventilator cannot reverse the brain death that has occurred and it would be wrong to give false hope that Jahi will ever come back to life,” he said.

AP Photo/Ben Margot, FileNailah Winkfield, mother of 13-year-old Jahi McMath, cries before a courtroom hearing regarding McMath, in Oakland, Calif. McMath remains on life support at Children's Hospital Oakland nearly a week after doctors declared her brain dead, following what was expected to be a routine tonsillectomy.

Durand said Jahi’s surgery was “very complex,” not simply a tonsillectomy.

“It was much more complicated than a tonsillectomy,” Durand said. He refused to elaborate, citing health care privacy laws.

Arthur L. Caplan, who leads the Division of Medical Ethics at NYU Langone Medical Center and is not involved in Jahi’s case, told The Associated Press that once brain death has been declared, a hospital is under no obligation to keep a patient on a ventilator.

“Brain death is death,” he said, adding, “They don’t need permission from the family to take her off, but because the little girl died unexpectedly and so tragically, they’re trying to soften the blow and let the family adjust to the reality.”

Often families confuse brain death with a coma or a permanent vegetative state, Caplan said.

“A coma is like a television that has a picture with a lot of interference,” he said. “There’s brain activity, but something’s not right. A permanent vegetative state is when the screen is all snow. Brain death is when the set is unplugged. There is nothing on the screen.”

Keeping Jahi on a ventilator is also likely to cost thousands of dollars a day, Caplan said, and because she has been declared brain dead, is unlikely to be covered by health insurance.

Earlier Monday, Christopher Dolan, the family’s attorney, vowed to keep Jahi hooked to the ventilator through Christmas. He said he would file an appeal if the judge orders her removed from the machine on Tuesday.

“I am confident she’ll live through Christmas,” a visibly weary Dolan said after the hearing. He said he is working the case for free after the family reached out for help a week earlier.

Given the very public battle over Jahi’s treatment, the judge pleaded with attorneys on both sides to continue speaking with each other and the family to help prepare for his eventual final order.

“This is a very, very charged case. The stakes are very high because there’s a young girl involved,” Grillo said.