The attack happened early on Friday, when the 32-year-old decided to take his chances in a river in Sarawak state despite knowing it was infested with crocodiles.
The labourer, who works at a nearby construction site, had just finished relieving himself under a bridge when the animal bit him from behind.
"Fortune favoured me when the crocodile let go after I punched it in the eye," he was quoted as saying by Malay tabloid Harian Metro.
"After being freed from the jaws of the crocodile, I found extraordinary strength to run and call for help even though my waist was extremely painful."
Several newspapers ran pictures of Pai, who like many Indonesians goes by one name, lying on his stomach at the Sarawak General Hospital with bandages on his waist and hip area.
Crocodile attacks have been a constant problem in Malaysia, with several deaths reported in the past few years.
Moral of the story: Use a proper toilet and stop polluting the river!