The 70-year-old underwent a 12-hour operation and spent 17 days in an intensive care unit, after being struck by severe abdominal pain in April. Bolsonaro, who was president from 2019-2022, has had recurring health problems since he was stabbed in the abdomen at an election rally in 2018.
His condition is now stable, according to the doctors.
Meanwhile, the trial is approaching where the former president is accused of attempting to stage a coup. It will be the first, since Brazil became a democracy in 1985, where a former leader in the country is accused of trying to force his way to power.
Bolsonaro risks a long prison sentence and not being able to run in next year's presidential election, something he had hoped to do.