Patrick Nogueira, 22, fled to his native Brazil shortly after the killing at the family's home in the village of Pioz near central Guadalajara in August 2016.
He returned to Spain in October 2016 and turned himself in to police after the corpses of the family were found in plastic bags at their home.
Nogueira's uncle Marcos Campos and aunt Janaina Santos Americo, both from Paraiba state in Brazil's northeast, had been dismembered in a crime that shook Spain.
READ MORE: Brazilian goes on trial for grisly murder of family in Spain
Marcos Campos Nogueira and his wife Janaina Santos Americo were killed alongside their two young sons. Photo: Facebook
On Thursday, he was handed the maximum sentence in Spain's criminal code: life imprisonment in which he will only be considered for release after at least 25 years in jail, according to the decision read out by judge Maria Elena Mayor at the court in Guadalajara.
The court acknowledged that Nogueira suffered from some form of "brain anomaly," but said that when he killed his relatives, "his ability to know and understand what he was doing was not restricted in any way."
Nogueira himself followed proceedings via videoconference from prison, near Madrid.
Wearing a black tracksuit, he was sitting down, arms crossed, his expression impassible.
The judge summed up the killings that took place on August 17, 2016.
Nogueira arrived at the house where his aunt and uncle lived in Pioz with pizzas and a backpack, in which he had a large knife, gloves, rubbish bags and duct tape.
He ate with his aunt Janaina and when she was in the kitchen washing dishes, he killed her by stabbing her twice in the neck in front of his two cousins.
The scene increased "the suffering of the children who shouted, hugged each other and remained paralysed by fear," Mayor said.
With the same knife, he stabbed three-year-old Maria Carolina and one-year-old Davi in the neck, killing them too.
Then Nogueira waited for his uncle, whom he stabbed 14 times in the neck. He dismembered both adults, put the bodies in rubbish bags, cleaned up the blood, spruced himself up and waited there until the morning to take the bus.
A month later, the bodies were discovered because of the "nauseating smell coming from the home," Mayor said.
Nogueira even joked about his victims with Brazilian friend Marvin Henriques via WhatsApp while committing the crimes.
Henriques is being probed for alleged collusion in Brazil.