Amid a raging battle for this last major Gaddafi stronghold, humanitarian groups in recent days have discovered a tableau of horror in the city’s main hospital.

More than 100 patients were lying in the hallways, in urgent need of attention. One man’s wound was swarming with worms. Another, whose legs had been amputated, had no painkillers. The morgue was overflowing.

The Ibn Sina hospital offers a glimpse into the desperation in Sirte, home town of fugitive former leader Moammar Gaddafi. Although the autocratic ruler was toppled in August and the world has recognized a new, pro-democracy government, the war isn’t over. Some of the fiercest fighting in the eight-month conflict has been unfolding in recent weeks in this coastal city.

Interim government commanders said late Sunday that the other major Gaddafi holdout, the smaller city of Bani Walid, had fallen. In Tripoli, the capital, bulldozers set to work Sunday tearing down the walls of Gaddafi’s Bab al-Aziziya compound — one of the most potent symbols of his reign.

But explosions continued to ring out in Sirte, where anti-Gaddafi forces are using tanks, artillery and mortars to smash their way into an area of the city center where loyalists are holed up and defending themselves with small-arms fire. Most of the city’s roughly 100,000 residents have been forced to flee.

For several days this month, the Ibn Sina hospital — one of Libya’s finest medical institutions — became a front line in the battle for Sirte. Outsiders gaining access to it in recent days have found operating rooms in ruins. Shattered glass twinkles like loose diamonds on windowsills. Skylights are blown out, and flies buzz around patients.

A handful of Sirte’s doctors and nurses managed to hang on through a fierce rebel bombardment in which the water supply failed and the building was raked with gunfire and artillery. When international medical teams arrived, they found the hospital’s personnel “completely burned out, confused, tired, not able to do their proper job,” said Gabriele Rossi, emergency coordinator in the city for Doctors Without Borders.

On Sunday, they were still struggling to take care of two dozen patients when the water again went out.

“Our problem, always,” sighed Abdullah Etbiga, a doctor who has not gone home for three weeks, as he sat in the hospital’s lobby. “Water, water, water.”

Libyan medical personnel started fleeing the hospital after the battle of Sirte began in mid-September. But not Etbiga.

“Everyone was afraid, but what can I do? I said, ‘I will stay with the patients,’ ” said the 40-year-old surgeon, who is unmarried. He rustled up food from the cafeteria and wondered if his siblings in Sirte were still alive.

Even before the fighting began, the hospital’s staff had noticed an ominous sign: Gaddafi had moved military forces, some from Tripoli, into vacant, brand-new buildings that belonged to the medical facility.

On Oct. 1, a young woman was in her brother’s hospital room changing his dressing when the first shell struck, recalled Maria Cristina Cruz, a nurse from the Philippines. “It hit here”— the nurse pointed to her stomach — blowing the woman apart.

Etbiga was catching a nap in another part of the hospital, exhausted from doing six surgeries a day, when he heard the boom. “I thought, ‘Maybe it’s outside the building,’ ” the doctor recalled. “Then I opened the door, and there was smoke everywhere.”

Pro-Gaddafi soldiers in the hospital fought back with a barrage of semiautomatic rifle fire and possibly other weapons, nurses said. Medical personnel raced to wheel patients into the basement and corridors to protect them from the shooting.

Over the next few days, most of the remaining staff members fled. Etbiga became the only general surgeon in a hospital that normally employs 200 doctors. He did vascular surgery, a chest operation, a Caesarean section. “Then the anesthesiologist left,” he said.

Without water and running low on medicine, the hospital stopped performing operations. The tiny staff struggled to feed the terrified patients and change their dressings as the building shook with blow after blow. In their care were pro-Gaddafi soldiers and wounded children. On Oct. 8, revolutionary forces seized control of the hospital.

Two days later, a team from Doctors Without Borders reached the hospital and determined that 15 of the patients were suffering from acute psychiatric problems, including post-traumatic stress disorder, suicidal thoughts and depression, Rossi said.

The morgue had run out of room. On Saturday, nine corpses in white body bags were on gurneys behind the hospital in 70-degree heat. They had been there at least 48 hours, Rossi said.

In the past few days, the hospital has begun to sputter back to life. International medical groups have donated medicine, water and personnel. The Red Cross has evacuated dozens of patients. Surgery resumed Friday. A refrigerated truck arrived Saturday night to hold bodies.

Doctors and nurses have arrived from Tripoli to help out, some wearing the red, black and green bracelets of the anti-Gaddafi movement.

They are part of the hospital’s new look. Revolutionary forces slinging AK-47s sit in the lobby, and the proclamations and poems praising Gaddafi have been torn down.

Etbiga is trying to contact doctors who left to urge them to return. “I want the hospital again working,” he said.

Still, there are constant reminders of the clashes between Gaddafi loyalists and revolutionary forces. Fighting rages in a small area about a mile from the hospital, and the sound of artillery echoes daily across the city. As Etbiga showed a visitor an operating room that had been wrecked by a shell, there was suddenly a loud boom.

“That sounded close,” he said nervously.