The operation, believed to be a first in Britain, was carried out during delivery, while the baby was half-in and half-out of the womb.
The baby, called Jaydon, was delivered by Caesarean section two weeks ago at the Royal Victoria Infirmary in Newcastle upon Tyne. He had a blocked windpipe, and surgeons had to perform a tracheostomy - inserting a tube into the windpipe - to enable him to breathe, before cutting the umbilical cord.
Surgery has been carried out before on foetuses inside the womb during pregnancy, but not during delivery. If the cord had been cut and the baby had been completely removed from the womb before the operation was performed, he would have suffocated.
Professor Steven Robson, a consultant in foetal medicine, said that a team of surgeons and anaesthetists had to be assembled rapidly when the baby's mother, Joanne Vasey, went into labour eight weeks early. Scans taken earlier in the pregnancy had revealed lung abnormalities that suggested a blockage in the windpipe.
Professor Robson said: "It was certainly fun and games for a while trying to put the team together in a few hours. The procedure itself was not particularly difficult. The remarkable bit was in making the diagnosis before the birth, which allowed us to be ready."
The operation began with the mother's abdomen and womb being opened to reach the baby, as in any Caesarean. The baby's head and chest and one arm were lifted out, and doctors checked to see that his windpipe was indeed blocked.
While the baby was still attached to the umbilical cord, the surgeons performed the tracheostomy. They then cut the cord and completed the delivery. The operation lasted 45 minutes.
Jaydon weighed 2lb 13oz at birth and is expected to remain in hospital for three months.
Ms Vasey, a business management student aged 17, told a newspaper: "For a time we had thought that he might die before the birth or we might lose him during the delivery. I can hardly believe that he has come through it all. He's still got a long way to go, but he's a star."