Tree branches break more frequently in the tropics where things grow and decay at an accelerated rate. So if you live high up in the forest canopies of Central and South America - as sloths do - you are occasionally going to come crashing down.

As a wildlife rescue and sanctuary manager, Sam Trull knows this only too well. She is used to putting in long shifts, calling in favours and generally pulling out all the stops to help sick and injured animals. Yet her efforts to help a pregnant sloth that fell from a tree reached new levels of commitment earlier this month, culminating as they did in what is believed to be the world's first birth of a sloth by Caesarean section.

It all started on 27 September when a hotel worker telephoned Kids Saving the Rainforest (KSTR), a wildlife centre in Manuel Antonio on Costa Rica's Pacific coast. He said that a sloth had been injured by falling from a tree. So Trull went to see it. She was originally a primatologist before founding the Sloth Institute Costa Rica, a specialist sloth rehabilitation and research facility based at KSTR, in August.

The animal turned out to be a female brown-throated sloth (Bradypus variegatus), the most common of the three-toed sloths. These cat-sized animals have a low-energy diet of leaves, twigs and fruit. They move very slowly and sleep for long periods - although researchers have found that in the wild they average nine to 10 hours per day, rather than the previously believed 15-18 hours.

When Trull inspected the sloth, she found she was having seizures and having difficulty moving her limbs.

"Seizures are normally indicative of some kind of brain injury and we knew she had fallen out of a tree," says Trull. "In the case of a skull fracture, we usually euthanise pretty much right away, but I checked her skull and it wasn't fractured. It was then I realised she was pregnant."

Having previously successfully treated monkeys suffering seizures, Trull gave the sloth steroids over three days. But then the sloth began to show signs of labour, including expressing milk from her mammary glands and having contractions.

"I could feel the baby kicking, which was cool," says Trull. "At least I knew it was still alive."

That night Trull only had a couple of hours’ sleep as she stayed up timing the erratic contractions. The following day, worried by the lack of any signs of imminent birth, she decided to take her to see a vet in the nearby coastal town of Herradura.

The vet carried out an examination as well as a CT scan and an X-ray, which confirmed the baby was alive but in a breech position – feet-first, when it needed to be head-first. Worse, the injured mother had a full bladder, which meant the baby was stuck like that. Sloths empty their bowels and bladders only about once a week, and can hold up to 30% of their own body weight in faeces and urine. So the baby was unlikely to be able to turn around for a normal, head-first birth.

"We determined it was an emergency, and that the only chance we had to save either or both of them was to do a C-section,” says Trull.

Sloth expert Bryson Voirin of the Max Planck Institute for Ornithology, near Munich, Germany, says he has never heard of a sloth being born by Caesarean section.

The operation was performed on 1 October. After consulting a senior colleague by phone, the vet gave the sloth a general anaesthetic and called in two assistants to help. First the vet drained the swollen bladder, then cut into the womb. After a procedure of around 30 minutes, the baby's head emerged.

The vet was concerned the baby's temperature was low, so it was placed on Trull's chest for warmth and to steady its breathing - a technique called skin-to-skin contact that is commonly used following human births.

The following day, the mother began eating and looking a bit better. But she still had neurological symptoms, and could not feed or properly take care of her offspring. The baby had a heart murmur and possible lung problems, and was not feeding properly. It died on 8 October, a week after its birth. The mother seemed to be improving but then had a stroke. She died the day after the baby.

"It was devastating but not entirely surprising," says Trull. "Ultimately it's not the quantity of life that counts but the quality. I'm glad he had a week, and that he had some snuggles with his mom. I was at least able to unite mother and baby before they died, so it might not have been a very long life but at least it was a life."

Trull and the work of the KSRF featured in the two-part BBC documentary Nature's Miracle Orphans, broadcast in August.