The three-time World Cup winner underwent surgery to remove a tumour from his colon and spent time in the intensive care unit at the Albert Einstein Hospital in Sao Paulo.
Pele, who will turn 81 in October, was delighted to be returning home to continue his rehabilitation.
"When the path is difficult, celebrate each step of the journey. Focus on your happiness," Pele wrote in an Instagram post.
"It's true that I can't jump anymore, but these past few days, I've been punching the air more times than usual. I am so happy to be back at home.
"I want to thank the entire Albert Einstein Hospital team, who made my stay a pleasant one, with a humane and very affectionate welcome.
"Thanks also to all of you, who from afar, make my life complete with so many messages of love."
Pele remains Brazil's all-time leading goalscorer, having found the back of the net 77 times in 92 appearances for his country.