The three-time World Cup winner was discharged late Monday from the private American hospital in the Paris suburbs where he had been taken after falling ill following an appearance at a promotional event with France striker Kylian Mbappe, AFP reported.
After arriving at the Sao Paulo-Guarulhos airport in Brazil, the 78-year-old was taken through the terminal in a wheelchair and was driven away in a van.
"Once again, thank God, everything went well. I'm alive. Long live Brazil," Pele said after he arrived.
"I would like to take this opportunity to thank all the Brazilians and all those who called the hospital, who called me, for my operation, to wish me a rapid recovery," he added.
In a statement on Monday on the Globoesporte.com site, Pele said his condition had required "medical assistance and surgery" but gave no further details.
Before he was discharged, current Brazil star Neymar, who plays alongside Mbappe for Paris Saint-Germain, paid him a visit at the hospital.
Neymar posted a photo on his Instagram account Monday of himself next to a smiling Pele in his hospital bed with the two holding hands.
Brazil's G1 reported that Pele had intended to come out of hospital on Saturday to return to his home country, but had been delayed by further tests.
The infection was not serious and was under control, members of Pele's entourage had said.
Pele has had several health scares in recent years.
A similar infection put him in intensive care in November 2014.
In 2016, Pele, who played 1,363 professional matches, scoring 1,281 goals, was unable to light the flame at the Rio Olympics because of severe pain in the hip.
In January 2018, he canceled a trip to London fearing a "stressful" and "tiring" journey.