A tiny baby at the centre of a heart transplant drama in Toronto has been given the gift of life.

On Tuesday night baby, Lillian O'Connor underwent surgery and received an infant heart to replace the damaged one she was born with 15 weeks ago.

Lily's plight was first publicized back in April when she was supposed to get a transplant from another very sick little girl, baby Kaylee, but doctors called it off when Kaylee somehow rallied after she was taken off a breathing machine.

Now, Lily has a new heart from a different donor, and her parents Kevin O'Connor and Melanie Bernard, of Prince Edward Island, are forever indebted to the other infant whose death meant that their child would have a longer life.

"Lily has lost another little one who will forever be near and dear to her heart. R.I.P.," Melanie wrote on her Facebook page.

Doctors at the Hospital for Sick Children say Lily's six-hour surgery was a success.

"Lillian is doing very well since receiving a new heart," Dr. Seema Mital, staff transplant cardiologist and associate scientist, said in a news release from the hospital.

"Her successful heart transplant is the result of months of an intensive team effort that involved nurses, intensivists, cardiologists, surgeons, anaesthetists, and many other health-care professionals. The team worked together, first to keep her old heart going for this long, and now, to successfully transplant a new one. While many challenges lie ahead, we are all really pleased at how well she's doing after a long and complex transplant surgery."

It's been a long emotional roller coaster for the Lily's parents, who have been at the hospital almost around the clock since she was born March 9.

Doctors had warned them Lily may be stillborn, as she was suffering from a rare congenital heart defect -- known as truncus arteriosus -- that causes a lack of sufficient oxygen in the blood. But she survived, and held on despite repeated medical emergencies including a staph infection, a collapsed lung and a racing heart.

Lily's mother, a manager with Veterans Affairs, told reporters: "she's got such strength."

At a press conference later Thursday, Lily's parents thanked the people who had supported them over the past few months, including their employers and members of the public.

Hopes were raised, and the story hit the headlines nationwide, when baby Kaylee Vitelli began failing and her parents, hearing about Lily's plight, sought out her family and made the extraordinary offer: Kaylee's heart.

Doctors even prepped for the transplant, but in the end Kaylee's condition improved. So much so she was able to go home.

That meant the agonizing wait continued for Lily and her parents, who knew time was running out.

Doctors told them this week an infant donor heart had become available. Their hopes and prayers had been answered.

As for Baby Kaylee, she was admitted to a hospital in Newmarket, Ont., on Thursday, after running a high fever, a spokesperson for the family said.

With files from The Canadian Press