The corpses of Marcos Campos Nogueira, his wife Janaina Santos Americo and their one- and four-year-old sons were discovered last month in plastic bags inside their home in Pioz near Madrid after a neighbour called the authorities over the stench.
The parents, both 30 and from Paraiba state in Brazil's northeast, had been dismembered.
A photo of the couple who were murdered with their young children. Photo: Facebook
Police said they suspected the assailant was Campos Nogueira's 19-year-old nephew, who was suffering from "egotism" and "narcissism" and had since returned to Brazil.
But the suspect, Francois Patrick Nogueira Gouveia, returned to Spain on Wednesday and "turned himself in voluntarily", a spokesman for the Guardia Civil police force told AFP.
Police detained him on arrival at Madrid airport early Wednesday afternoon.
Earlier this month, the Guardia Civil said they had "a lot of reasonable evidence and clear proof" that the youth was responsible.
The suspect lived with the family for four months in Torrejon de Ardoz, also near Madrid, before the couple moved to a quiet residential area in Pioz.
He remained in Torrejon de Ardoz, without a job.
When the bodies were discovered, police said there was no sign of forced entry.
Police said the teenager had a plane ticket to return to Brazil in November, but had changed the date some 24 hours after the bodies were discovered, flying back on September 19th.
The suspect has a violent history, police said, noting he had brutally assaulted a teacher back in Brazil.
Authorities issued an international warrant for his arrest and Spain's justice ministry asked for his extradition, but Brazil refused as it does not extradite its nationals.
The Guardia Civil said the suspect's "voluntary" return materialised after "a series of conversations" with his lawyer.