Exposed to the air by the surgeon's knife, a baby's heart, the size of a small plum, is beating vigorously. Two theatre nurses count and re-count their trays of instruments. The anaesthetist studies her monitors and adjusts a couple of dials. And consultant cardiac surgeon Conal Austin steadily goes about the business of putting 10-day-old Finn Jones safely on to the heart-lung bypass machine.

He lifts, gently manipulates, then cuts the aorta, and glances up. "No going back now," he says drily. We're 50 minutes into a five-and-a-half-hour marathon "cardiac switch" operation to replumb baby Finn's circulatory system, which is currently working as two disconnected circuits: "blue" blood is pumped round his body but cannot reach his lungs to be reoxygenated, while brilliant red, oxygen-rich blood flows into and out of his lungs with no way of reaching any other organs.

Under swathes of green drapes in the operating theatre, all that can be seen of Finn is a small rectangle of chest. He is on bypass, his heart stilled as surgeons begin the delicate, precise cutting of blood vessels leading into and out of the upper atriums. Tiny curved needles are used to stitch each vein and artery in its new location. Austin's white latexed fingers swiftly tie and knot, tie and knot, tie and knot each suture. Above us, the monitors display Finn's vital signs. "That blood pressure's too high," Austin snaps at one point to the anaesthetist. "Get it down."

Until a few decades ago, infants born with this condition – transposition of the great arteries – were known as "blue babies" because of the faint purplish tinge to their skin. They would generally survive until the tiny valve between the two upper heart chambers – open in utero, and which on birth allows just enough "mixing" of oxygenated blood with oxygen-starved blood – finally closed. Then, suddenly, they would die.

The only thing that's kept Finn alive until today's operation is a procedure carried out within hours of his birth, to tear a hole between the atriums so that the two types of blood could continue to mix. A deflated balloon was fed up a vein, into one heart chamber and then, through that tiny, yet crucial valve, into the other. It was then inflated and – there's not really another word for it – yanked back to create a larger hole between the two chambers. The mixing of blood this allows has enabled Finn to survive, albeit on oxygen saturation levels of only 80%.

It's a standard procedure, but it is also risky. "You have to tug quite decisively, but not very far, else you can tear the heart right away from all the vessels and then, well, it's game over," consultant cardiologist Dr Thomas Krasemann explains later. The echocardiogram playback showed Finn's heart jumping violently as the balloon was pulled through the valve. You must need nerves of steel to do this job. The registrar who performed the procedure under supervision certainly looked relieved it had gone well.

When I first saw Finn, a couple of hours before this procedure was carried out, he was ventilated and on morphine. His mother held him gingerly, careful not to dislodge any of the intravenous lines attached to his tiny arms and legs via cannulas held in place with tape. Other lines fixed to the skin with stickers led to beeping monitors that kept track of his heart rate and oxygen levels, and a ventilator tube was taped across his cheek.

He'd been born just after 2.30 that morning at Evelina London children's hospital at St Thomas' and was whisked away to the neonatal intensive care unit (NICU) a few minutes later. Now he was being cared for in a large room with big windows overlooking the Thames, holding four other poorly or premature babies. While he weighed a healthy 3.5kg, his waxy pallor that first day contrasted markedly with his mother's happy glow. Seeing her, radiant as she held her very sick baby, instantly transported me back five years.

My eldest son, Sam, was born by emergency section, extremely ill, at 33 weeks. He was immediately ventilated to support his breathing, then transferred that night from our district maternity unit in Macclesfield to Liverpool Women's hospital 40 miles away, where he spent two weeks in intensive care. For 36 hours, a massive infection had him teetering on the brink of life and death. Two years on, his brother Mungo arrived healthy and at term, but three weeks later we woke in the early hours to find him limp, grey and barely breathing. Once again it was sirens, doctors who did not offer reassurances, ventilation at a district hospital and an ambulance transfer from Kent to intensive care at the Royal London in Whitechapel. Sam and Mungo are now healthy little boys, but without expert medical intervention, both would have died.

Spending time on an NICU is gruelling for parents as well as for babies. Emotionally, financially, logistically, too, as neonates needing specialist care are often treated far from home. When Sam was born, my partner and I would set off at eight each morning and drive an hour and 20 minutes to Liverpool to see him, full of trepidation at how the night had gone. This was the routine: go up to the unit to see Sam, hope to catch the consultant, glean as much information as possible about his condition, then, if we were lucky and Sam was stable, try for some skin-to-skin "kangaroo care". I would take off my top and sit down, while the nurse would strip Sam to his nappy and carry him carefully, trailing all his lines, from his incubator. She'd place him on me, make sure we were settled and pull up screens for privacy. But we were in the middle of a room with other parents, busy medical staff and beeping machines: it wasn't really private. When my precious hour or so was up and it was time for him to be scanned again, or fed, or have another blood test, I'd head off to the "milk room" to express. Then back to see Sam.

Changing his nappy was one of the few things we could do for him, but sometimes he was too ill for us to handle. If the staff were going to do a procedure such as putting in an intravenous line, which involved finding a vein in his leg or arm, I couldn't watch. We'd go and grab an expensive sandwich from the hospital cafe, then I'd go and express again. A final tiptoe into the unit to say goodbye (Sam was often asleep or sedated, so couldn't respond to us) and we'd leave him in his little nest of rolled blankets in the incubator – not my womb, but the closest thing the nurses could fashion. Then we would drive home, arriving hungry and tired at around 7pm. And all the time, underlying everything, was fear. We did that every day for five weeks, but some parents do it for months. It takes a tremendous toll on your relationship. Other siblings are neglected. The stress can affect your mental health.

Since the time I spent in an NICU, I've wanted to write about what "intensive care" really means, because it's not just the baby who receives it, but the parents, too. Visits to such units from anyone other than immediate family are discouraged to reduce the risk of infection, but Dr Tim Watts, consultant neonatologist and clinical lead at the Evelina London NICU, gives me and my photographer friend Colin permission to approach Finn's parents. We want to ask if we can follow their journey with their baby from intensive care through to discharge.

Finn at three days old with his father, Philip. Photograph: Colin McPherson for the Guardian

It's not just the neonatologists and neonatal nurses who provide the care here: the effectiveness of a unit relies on a diverse team of highly specialist support staff. And though everyone's primary role is to tend to extremely unwell, unstable babies, it's the kindness of staff that's instantly apparent: everyone is acutely aware that parents are going through the worst experience of their lives.

Babies born with a heart condition at St Thomas' are lucky. It's the only place in London with a maternity unit, intensive care, cardiology specialism and paediatric intensive care (where babies go after an operation) all on one site.

Finn's heart problem had been diagnosed early on, and confirmed from a scan six months into the pregnancy. For first-time parents Kathryn, 32, and Philip, 31, realising he had a life-threatening condition was devastating, but both pay tribute to the relationship they were able to develop with the team planning the first hours and days of Finn's care, which gave them faith that their longed-for family had a future.

Following the balloon yanking procedure, Finn was moved out of intensive care once his oxygen saturation levels had improved. Two days on, he's looking a bit pinker than before. Cradling his son on his lap, Philip, like his wife, is shining with happiness and relief that Finn has survived the first hurdle. Remembering back to the day of the scan, he says the first shock came when "they drew us a picture of his heart, and showed us how his circulation wouldn't work when he was born. It was like a punch in the stomach."

"It felt like for ever till we heard the words, 'It's fixable,'" Kathryn recalls. "And then, pretty fast, despite the fuzziness and information overload, we actually felt lucky to live in this country, near London, with the NHS. When they induced me, though it was just us and my sister and the midwife in the room, it was planned so that all the best specialists were waiting outside that door. And we knew we wouldn't have to move from this spot until his heart op was done and he'd recovered."

It's late afternoon in the high-dependency unit and although it is open to parents round the clock, for those who aren't sleeping at the hospital, five o'clock is often their last chance to see their baby for the day. By the far window, a couple huddle at a bedside. There are three other neonates in here but, apart from the constant beeping of machines, it's quiet. There's very little chat; parents are so bound up in their own child's prognosis that there's scant interaction between families.

Kathryn arrives back at Finn's see-through plastic cot holding out a small bottle containing a few millilitres of breastmilk. "It's not very much," she says apologetically, handing it to Finn's nurse. "Really, there's hardly any."

"No, it's brilliant. It's perfect," he says, whisking the bottle away ready for the next feed. Here, for very premature babies whose digestive systems risk damage if they're fed on formula, breastmilk is seen as medicine and every last drop is cherished.

Settling herself by her son's cot, Kathryn smiles wearily. She has been staying in special parents' accommodation on the hospital site, but she looks drained. Expressing milk can be shattering. It's emphasised to new mothers whose babies can't feed normally that you need to express at least eight times a day. You can't skip doing it in the early hours, either, because that's when prolactin levels, which stimulate milk production, are at their highest. Expressing takes ages by hand, using an electric pump can be painful, and the volume produced, at least at first, tends to look pathetically small. On the other hand, providing breastmilk is the only thing that a mother can do for her baby that the medical team cannot, and it's why so many make the effort to keep expressing.

"I'd not intended to breastfeed originally," Kathryn says, "but when I realised how ill he'd be and how much difference it would make, it was straight away, yes, of course I will. But you do feel the pressure, and sometimes you're exhausted."

"When a baby is very premature, mothers are often in acute distress, fearing the future, worrying about the upheaval at home," says Marcia Chilton, the sister responsible for training and practice development on the unit. "That stress doesn't help with getting milk production under way. So we need to support, calm and encourage mums, over and over again if that's what they need from us." With this, she whips out a scarlet knitted "breast" to show the way she teaches women to stimulate the hormones that promote lactation. It's a much-needed comedy moment.

Intimate time alone with your child on the unit is precious and hard to come by, and yet, when you get it, sometimes you don't know what to do. "It's very easy to feel distanced from the small poorly person lying in a plastic box, attached to all those monitors with lines going into every available vein," Kathryn says. But then she lights up. "When I fed him late last night, no one was around bothering us or doing things to him. He went straight on the breast. I just sat here holding him, between about 10 and 12. It was lovely."

Finn at three and a half weeks with a nurse in the neonatal intensive care unit. Photograph: Colin McPherson for the Guardian

As well as being a world-class research centre, the Evelina has pioneered the practice of discharging newborns as early as possible, often well before their due date. "The smallest baby we ever discharged was 1.2kg," says neonatal nurse Katie Norris, who works on the only seven-day-a-week neonatal outreach team in the capital, dedicated to providing daily support to babies going home to either Lambeth or Southwark.

Early discharge is not just about lessening the disruption to families and keeping clinical costs down but, vitally, about removing babies from a hospital environment in which bugs are rife, no matter how stringent the infection control and cleaning regime. "We can discharge them even if they need oxygen," Norris continues. "They can be tube-feeding as long as they're managing to take 50% of their milk orally without getting too tired. Or if they're withdrawing, they can go home on a morphine programme."

I look puzzled. "That's babies whose mothers were on drugs during pregnancy," she explains. "Quite often, they'll go home to foster carers." She suddenly looks sad. "It's the withdrawal babies we find the hardest," she says quietly. "Their parents will often conceive again and again, and some of the babies are born and are in agony."

By the end of five weeks in hospital with Sam, I felt weepy, anxious and unable to cope. But I still think I'd have balked at taking him home any earlier than we did. Parents do get nervous, Norris acknowledges: "But it's about preparing them, teaching them how to use the equipment and the drugs, so that they feel more confident."

On average, as long as a baby is medically fit for discharge, he or she will go home at the equivalent of 34 weeks gestation. This simply wouldn't be possible without the outreach team being on hand every day of the week. "We're constantly trying to find ways of getting babies home sooner," Norris says. "They thrive so much better with their family around them, they breastfeed better, they come off oxygen quicker."

The following Thursday, Colin and I arrive on the unit on the morning of Finn's surgery. We have permission from Kathryn and Philip to go into theatre and watch. Despite the hospital's 97% success rate with this operation, open-heart surgery on a newborn is a very big deal.

For Finn, though, there isn't an option. I tiptoe into the ward. Kathryn and Philip are sitting close together by his cot. They've been crying. "No, no, this is a good day," Kathryn insists, smiling.

In the soothingly impersonal parents' room just along the corridor, Dr Watts makes time to explain what drew him to neonatology. An Australian who came to London after qualifying, he is without doubt the most approachable, empathetic, smiliest consultant I've ever met. Neonates are, he says, "volatile". Continuous painstaking interrogation of every aspect of a baby's condition is critical to a good outcome. "In this job it's an advantage if you have very high attention to detail – you have to be really quite obsessional about it." He grins.

Even for highly trained staff, it's easy to forget, he says, that a baby who appears stable can have a condition that means it's very finely poised between living and dying. It's only hour-by-hour clinical management that keeps these fragile infants on the right side of that wafer-thin edge.

"The intensity of working in a neonatal care unit doesn't suit everyone," he acknowledges. And there are ethical dilemmas that test every member of a team. This unit, like virtually all the others in the UK, does not offer intensive care to babies born at less than 23 weeks. "And some parents of 23-weekers will question whether it is right to embark on intensive care once we've explained the possible outcomes. Being honest, they are often not good. And at that gestation, most clinicians would be accepting of parents' strong view that intensive care would be too traumatic, given the chances of a good life for that baby… It is then, of course, extremely difficult for everyone in the team when a baby is born at 23 weeks in good condition, very vigorous, and the parents decide they don't want intensive care."

There is, too, the other scenario, where parents are begging for intervention, but everything points to an outcome so disastrous that instigating highly invasive procedures is felt to be unethical. Communicating this to people who are desperate, in front of their dying baby, in a unit where so much cutting-edge technology is ready and waiting to be used, must take an enormous toll.

"Actually, the family aspect of my work – communicating with parents and helping them deal with babies dying, or living with an outcome that perhaps isn't what we'd all hoped for – well, that's incredibly rewarding, because it makes a difference how you do it," Watts says. "Those interactions stay with people for a very long time."

I recall my worst, most vivid memory of our time in hospital with Sam: a moment of poor communication that left me feeling terrified, disregarded and shaky with rage. Sam had already been transferred three times and had almost died of an infection, and I wanted him to stay where the doctors knew him best. But a consultant I'd never met swished in and said that because Sam had been stable for 24 hours, he had to go back to our local hospital. I pleaded, "But he's your patient now. He's barely over the infection and another ambulance transfer is going to put him under more stress. If you do it, it'll be completely against our wishes." He'd told me Sam had to go because they needed his cot for other babies. "But why couldn't the other babies go where Sam was being shunted off to, if he still needed intensive care?" I say, on the verge of tears.

"The transfer time is incredibly stressful for parents," Watts says gently. "We do know that."

Even when babies just go from intensive care to the high-dependency room next door, he explains, parents' anxiety spikes when they see, for example, that their child is suddenly "only" getting one-to-two, rather than one-to-one nursing care. "It's different for the staff," he says. "At that point we're feeling pleased, because we know the baby is doing well enough to be moved."

There are, he says, "really correct reasons" for moving a baby back to a hospital nearer to home, not least to relieve parents of the strain of daily travelling, and to help establish breastfeeding, which can be done only if you can be in close contact for most of every day. "For parents who've built up trust in the team at a particular unit, and especially if they perceive that their child wasn't looked after well elsewhere," he adds, "the idea of going back can be hugely difficult to accept."

Another reason very sick neonates are regularly whizzed up and down motorways between different hospitals is that there aren't enough neonatal cots or qualified neonatal nurses in the country. This means that if a baby is suddenly born early or very unwell, there's often an urgent scramble to find a space.

"We have a 'crash' cot we try to keep free for emergencies, and we'll pretty much move heaven and earth to say yes to a baby born in one of our network of hospitals," Watts says, "but it can be a juggle, and it takes a huge amount of consultants' and senior nurses' time, phoning round hospitals and looking at the babies we've got, assessing if they're well enough to be moved to free up space in intensive care. If not, well, how do you make a neonatal cot available when you don't have one?"

Finn with his mother, Kathryn. Photograph: Colin McPherson for the Guardian

From the start of the operation at 1pm to the final closing of Finn's chest at around six, neither Conal Austin, his assistant surgeon Michael Murphy nor any of the six other theatre staff takes a minute's rest, a loo break or even a sip of water. The quality of concentration in the operating theatre is beyond intense, and yet there's also a bit of chat – the surgeons are focused, yet relaxed.

How much does this type of surgery cost? "If a health authority abroad wants to book this operation here, they have to deposit 50 grand in the hospital's account," Austin says. "Depending on how long you need intensive care, you might get some change out of that. Or you might not." The NHS won't be seeing any change out of Finn.

The operation itself has been a total success. "It's great, because it is a complete fix, but it's one of the most technically demanding ones I do," Austin says as he hangs around in theatre to make sure any internal bleeding has stopped. Finn is wheeled over to paediatric intensive care, where a dozen or so pink-overalled nurses and doctors have gathered to receive him. In the corridor outside, Kathryn and Philip are told that it's gone "as expected". They light up, laughing, clasping hands, fizzing with relief.

Two days later, I get a text. "Finn is not doing too well. He has a big fight on his hands at the moment. We will know more in a few days."

The situation is far worse than we imagine. Finn survives, but only just.

"One of the consultants knelt down next to us, explaining everything so carefully, nothing rushed," Kathryn says. "And I'll never forget the words he said: 'There's nothing more medically we can do for your baby.'"

"I fell apart that day," Philip recalls. "When doctors say they've given him every drug and they have no idea what's going on, that's when you hit rock bottom."

It's early December and we're sitting in their house in Kent with Finn peacefully asleep in his Moses basket. A Christmas tree twinkles in the corner. He's nine weeks old now, 6cm longer than when he was born and just back up to his birth weight. But where he had a single neat little scar, he now has a deep, livid line, and another scar that goes right across his abdomen. His family has endured an excruciating emotional rollercoaster.

A day on from the heart surgery, Finn's blood pressure plummeted and surgeons had to reopen his chest. "They couldn't work out what was wrong, because his heart was beating beautifully," Philip says. "Conal was called. He missed his son's birthday to come in. He stood there and did not take his eyes off the screens, watching Finn's numbers as they got worse."

Pumped full of fluids and every available drug in an attempt to boost his blood pressure, Finn failed to respond and was within minutes of a decision being taken to put him back on to bypass. This would only have bought time – it's not a cure and is used only as a last resort – to allow his body to stabilise and recover.

Why he deteriorated so disastrously is still a mystery. Another operation was carried out to repair a perforated bowel, then the team had to deal with fluid on Finn's lung. He was finally discharged on 5 November, "with fireworks going off as we drove home", Philip says.

Colin had travelled to London after Finn's bowel operation to take more pictures of the family together; they show a thin, wan-looking tot who looks as if he's gone 10 rounds with a boxer. Seeing him now, sleeping calmly as we talk, his little head poking out above his blanket, it's hard to grasp how such a small body could withstand such trauma in the space of just 10 days.

For Kathryn in particular, support from Finn's intensive care nurses made all the difference to her ability to cope every time his health took a downturn. "On the worst day, I said to one of them that I was finding it really hard to touch him, or relate to him at all," she says quietly. "They'd chilled him to shrink his blood vessels and boost his blood pressure, he was grey, all swollen up with fluids; he looked dead. And Clare, his nurse that day, was amazing. She said, 'He knows the difference between your touch and the doctors', he can hear you, he can smell you, and that can help a baby to recover.'" Every day, Clare and Stacy, Finn's other nurse, made time to write a diary entry, so his parents would always know what had been done and how he'd responded.

The day we see him in Kent, Finn has just come off all his heart drugs. Safe at home, he's been given back his life – and so have his parents.

"Behind the 97% success rate for that operation, there can be a lot that happens – the statistics often mask what these babies go through to survive," Watts says. "But this job, for a doctor, is intensely satisfying. You start with an ill child and very often they will get better. Even the 25- and 26-weekers, 80% of them go home. And it is fabulous when you wave them off."