OAKLAND -- With time running out for a brain-dead Oakland girl, the family of Jahi McMath and officials from Children's Hospital Oakland on Friday agreed to allow Jahi's mother to remove her from the hospital as long as she takes full responsibility for the girl's care.

The compromise forged in Alameda County Superior Court may put an end to weeks of wrangling over what to do with the 13-year-old girl, whose family hopes she will revive even though experts say that is not possible.

It still isn't clear how the family would move her, or where they would take her.

They need to find a doctor who will surgically insert tubes for breathing and feeding and a location where that can be done. During a day marked by a flurry of legal proceedings after an agonizing three-week battle between the family and the hospital, Superior Court Judge Evelio Grillo refused the family's request that he order the hospital to perform those operations.

The hospital says it is unethical to operate on someone who is dead, but Jahi's mother, Nailah Winkfield, clings to hope because her daughter's heart is still beating.

The family's lawyer, Christopher Dolan, speaking outside the courtroom, said the family is fighting for a feeding tube for Jahi because it had been 24 days since she had any nutrition.

Jahi had tonsil, nose and throat surgeries on Dec. 9 and was declared brain dead two days later after she developed complications. Medical experts say that without nutrition, a patient's body starts suffering irreversible damage within two to four weeks.

A temporary restraining order preventing the hospital from removing the ventilator that's keeping her lungs moving and heart pumping expires Tuesday at 5 p.m.

Friday's agreement came as both sides softened their stances after an emotionally taxing court battle that left the hospital's attorney nearly in tears outside court.

"It's horrible that this child has died," said Douglas Straus, an attorney for the hospital, before choking up. "It's also horrible that it's so difficult for her family to accept that death ... ."

The hospital will allow a transfer team to enter the facility and move Jahi out; her entire health responsibility and consequences of the move would then be transferred to her mother, according to the agreement.

Jahi's tubes from the hospital's ventilator will be removed and placed into the transport team's equipment, along with other devices, and her body will be moved from the hospital's gurney to a new one, the agreement states. Her medical records, medications and a status report will be handed over and the hospital will sever its ties with her.

"(Winkfield) must agree that she shall be wholly and exclusively responsible for Jahi McMath the moment custody is transferred in the Hospital's pediatric intensive care unit and acknowledge that she understands that the transfer and subsequent transport could impact the condition of the body, including causing cardiac arrest," according to the agreement.

Dolan called the agreement a "victory in terms of getting us one step closer," but the family still needs to find a doctor to insert the breathing and feeding tubes.

"Until this agreement was just made, everything was in flux. This just removes all those impediments," he told a throng of media outside court. He said "there are doctors who are willing to do the procedure" but would not name them.

Initially, he said, a critical care ambulance will take Jahi from the hospital, but the procedures will not be done there.

"Nobody's going to do an operation while driving down the street. That's absurd," he said.

It's unclear what ambulance company will remove Jahi from the hospital, but an air ambulance company that quoted a price for flying Jahi from Oakland to Long Island, N.Y., where a facility agreed to take her, said Friday it had not been contacted by the family and no flight was imminent.

The hospital originally required an agreement from an outside facility willing to take Jahi, but backed off that when the family agreed to take "her body unconditionally," hospital spokesman Sam Singer said, adding that Children's Hospital still has not heard from any agency or transport company willing to take her.

"It's now in Mr. Dolan's court," Singer said. "They will have to give us a time and date."

After the lower court hearing, attorneys headed to federal court blocks away in Oakland, where a magistrate presided over a conference between attorneys for the family and the hospital. After about six hours, attorneys for both sides emerged, saying that no new agreement or order had come out of the meeting.

"This whole day has been about clarity ... what doors have to be opened and what obstacles need to be removed," Dolan said after the discussions ended around 7 p.m. "We are confident that we will be able to accomplish what we need to do."

Jahi's family appeared buoyed by the agreement as they spoke Friday evening.

"When you love your children the way I love mine, you go above and beyond," Winkfield said. "Every time I go in and see Jahi, it makes me want to keep pushing forward.

"When I talk to her, she moves. ... If I felt my child was suffering, I would not keep her on that machine."

Jahi's uncle, Omari Sealey, added: "The fight isn't over. We are very optimistic."

Dolan filed a complaint in federal court on Monday, asking for an additional order forcing the hospital to keep the girl on the ventilator and give her the breathing and feeding tubes, saying that the hospital was violating the family's freedom of religion and privacy by forcing them to take the girl off the breathing machine. A federal judge will hear arguments Tuesday afternoon, about four hours before the Superior Court order is set to expire.

In papers filed with a state appeals court Friday, attorneys for Children's Hospital said a demand that doctors perform surgery on Jahi's body was "grotesque and unprecedented." The hospital's chief of pediatrics, Dr. David Durand, said that hospital staff members were "demoralized" by the court's order forcing them to continue caring for a dead girl. That court took no action Friday.

Elsewhere Friday, an Alameda County coroner's office investigator said Jahi's death certificate has been issued and that it listed her name and date of death as Dec. 12, the day she was declared brain dead after her sleep apnea surgery ended with complications, but listed no cause of death pending an autopsy. Officials have not yet made that certificate public.