President Joko Widodo signed a decree yesterday introducing the tougher measures, which also included fitting monitoring devices to offenders after their release from jail, in response to public anger at the fatal gang-rape of a schoolgirl.
The 14-year-old was snatched by a group of drunken men and boys on western Sumatra island in April and was found days later in woods, tied up and naked.
The case sparked a national debate about sexual violence and as more reports of sex attacks emerged, pressure mounted on the government to take action.
"Castration is intended to have a deterrent effect and prevent repeat sexual offences," said lawmaker Abdul Malik Haramain, from the Islamic party the National Awakening Party, which is part of the ruling coalition.
Also Read
He insisted that castration would not violate human rights, as offenders would go through a legal process before the punishment was handed down.
Twitter user Boenga Indah also defended the new laws: "Those who disagree with castration and the death penalty, who said that it's a human rights violation -- do you think rape and murder are not human rights violations?"
Hartoyo, a prominent gay rights activist who has campaigned against the new punishments, said the regulation amounted to an "act of vengeance".
"It only shows that the government is panicking and has no real understanding about sexual violence," added the campaigner, who like many Indonesians goes by one name.
Nur Kholis, of the National Commission on Human Rights, said his group was generally against the death penalty and did not believe that castration would have a deterrent effect.
The presidential decree brings the new punishments immediately into effect, although parliament could later overturn them.
Under previous laws, the maximum sentence for rape -- including of a minor -- was 14 years in jail.