Life was on a knife edge for kakapo chick Espy-1B, a bird whose species lives on the brink of oblivion.
After hatching with a life-threatening lump on its head, Espy was taken first to Dunedin, then to an animal hospital in Palmerston North for pioneering bird-brain surgery.
The bird, one of just 144 remaining kakapo, hatched in the wild at Whenua Hou/Codfish Island west of Stewart Island and was in the care of the Department of Conservation kakapo recovery team.
After rangers noticed a lump on the head it was sent to the Dunedin Wildlife Hospital for a CT scan.
"The CT scan showed that the plates of its skull had not completely fused and the fontanelle was still open," said Professor Brett Gartrell, the director of the Wildbase Hospital at Massey University in Palmerston North.
"The chick was hatched with a hole in its skull that allowed part of the brain and dura - the tough barrier around the brain - to herniate out."
In humans the gaps between the bones of the skull fill in with bone after birth. In birds, the skull usually finishes fusing together before hatching occurs.
Gartrell said the concern with Espy was that if the exposed tissue was damaged the brain would be open to trauma and infection.
"With only 144 kakapo left in the world, this condition could be life-threatening for the critically endangered bird, so action needed to be taken, but nothing like it had been attempted before in avian medicine."
Vets including from Auckland and Wellington zoos and the Dunedin Wildlife Hospital decided surgery was the best option and Air New Zealand flew Espy to Palmerston North at no charge.
On Monday, Gartrell led a team of vets and veterinary technicians in performing the high-risk, pioneering surgery, which was based on the same kind of operations in humans and other mammals.
After opening a flap of skin, they trimmed out the bulging dura and a tiny piece of bird brain. A small square of synthetic mesh was sutured into place and infused with bone marrow before the skin flap was sutured back over the top.
The 8-week-old chick is making a good recovery and was expected to be moved back to the Dunedin hospital this week.