Two-month-old Naiara received a heart transplant from a donor heart that had already stopped beating and had a different blood type.
The head of children's heart surgery at the Gregorio Maranon Hospital said the technique didn't exist for children three years ago.
He said the successful operation opens the way to saving more infants in need of heart transplants who are too young to use ventricular support machines until they get a compatible donor.
Naiara was diagnosed with a congenital heart disease before she was born and only weighed seven pounds when the surgery was performed.
The head of the Children's Cardiac Transplant Unit said she's the smallest baby that has had a heart transplant at the hospital.
Little Naiara is still recovering at the hospital.
With 37.4 donors per million people, Spain was the world leader in transplants last year, according to the World Health organization.