Two-year-old Paul Iga was playing near his home about 800 metres from the shores of Lake Edward in west Uganda.
The hippo grabbed him in its huge jaws and was swallowing him when a man saw what was happening and started frantically pelting the animal with stones.
The startled hippo regurgitated the child and lumbered off back towards the lake.
A Ugandan police spokes- man said: “This is the first such incident where a hippo strayed out of Lake Edward and attacked a young child.”
The hippo had grabbed the boy from the head and swallowed half of his body.
The spokesman added: “It took the bravery of one Chrispas Bagonza, who was nearby, to save the victim after he stoned the hippo and scared it, causing it to release the victim from its mouth.”
The boy was rushed to a clinic, then transferred to a hospital in the nearby town of Bwera, close to the border with the Democratic Republic of Congo.
He was given a rabies vaccine as a precaution then released back to his parents.
Although herbivores, hippos can be highly aggressive when they feel threatened. They are estimated to kill at least 500 people a year in Africa.
The power of their bite is three times greater than that of a lion.
Local people were warned to be vigilant, with the police spokesman saying: “Although the hippo was scared back into the lake, all residents near animal sanctuaries and habitats should know that wild animals are very dangerous.
“Instinctively, wild animals see humans as a threat.”