MEXICO CITY — Most of the 25 babies pulled alive from the rubble of buildings wrecked by two earthquakes have gone home to their families, but pediatricians warn they may suffer long-term damage from being buried for up to a week.

The discovery of the newborns, trapped in the collapsed wings of the Juarez and General hospitals, provided a rare note of joy as Mexicans dug out from the Sept. 19 and 20 earthquakes and counted 8,000 of their people dead.

As each infant was pulled from the shattered concrete slabs, bystanders laughed and cried. Some shouted ''Viva Mexico,'' as if to reaffirm the country's will to survive one of its worst disasters.

More than a month later, only three babies remain in the Infant Hospital of the 17 that were taken there. At the Military Hospital in a northern suburb, only two of the eight babies treated there remain in the nursery.

''We have let almost all of them go home, and these little ones are doing very well,'' said Dr. Lucia Madrazo, waving her arm at the incubators and cribs in the large, sunny intensive care unit of the Infant Hospital.

''This is a work of love; we are working day and night,'' she said.

However, the doctor spoke quietly when asked if the babies would suffer long-term damage after being buried four to nine days without liquids, postnatal care or their mothers' love.

''We really don't know if they will be normal,'' she said. ''Right now they appear to be, but we cannot say as we have not seen such a situation before. We will keep close watch on these children to see how they develop biologically, psychologically and how they will adapt into society.''

Two babies died at the hospital, one a girl dubbed ''Mary Miracles'' and another unidentified boy. Doctors said both died of massive infections after they were found near decaying bodies.

Three babies, known only by their surnames, are still in Madrazo's care.

Dr. Pablo Rivera Hernandez, a hospital administrator, stressed that doctors are in ''uncharted territory'' in trying to determine whether the infants will suffer damage later.

''Even though babies are born with between 10 to 15 percent liquid excess and they may not have suffered from any shortage, there may be problems with the central nervous system,'' Rivera said.

''We will continue studying them and comparing them on growth charts until they are eight or nine years old,'' Rivera said. ''We will also have to determine if there is any damage to internal organs or to the brain.''

Although Rivera pointed out that only 15 of the 125 babies in the General Hospital nursery survived the quakes, he refused to call them ''miracle babies.''

''Even though this is a religious country, I don't think we can say it is a miracle they survived. They were lucky not to have been crushed, but afterward they were prepared to continue living.''

Rivera said the environment of the collapsed buildings ''resembled in many ways what the babies knew for the first nine months. It was dark, their movement was restricted, and it was relatively silent.''

The fact the infants were also tightly swathed in blankets and the ability of their kidneys to recycle water during the first days of life, much like animals in the desert, helped ensure their survival, he said.

''As these little ones were too small to have any anguish or to panic, they used less calories than an adult in the same situation would have.''

Although some of the babies' mothers died in the quakes, none of the infants is without family, as their fathers, grandparents or other relatives have stepped forward to care for them.