The legislation applies to those above 21 who are convicted of crimes such as culpable homicide, rape and sex with minors, who are deemed to be at risk of reoffending upon release.
In a speech in parliament, Law and Home Affairs Minister K. Shanmugam said: "An offender who continues to pose a real danger to others should not be released."
He gave an example of a man jailed for raping his 6-year-old stepdaughter, who, after his release started sexually assaulting his sister's granddaughter who was 10 in 2015. In 2017, he sexually assaulted the girl’s younger sister who was 9.
"We have to deal with these kinds of menace and protect our society," said Shanmugam.
The new law means that instead of being automatically released after completing their prison terms, such offenders would need the home affairs minister to decide that they were no longer a threat to the public.
The minister would be advised by a review board made up of experts such as retired judges, lawyers, psychiatrists and psychologists, and the offender and his lawyers can make representations to the board. Those found unfit for release will have their case reviewed annually.
Singapore estimates this law will affect fewer than 30 offenders a year.
The United States has a similar law - for sex offenders who are considered likely to reoffend - in 20 states, the District of Columbia, and the federal government.
In Singapore, the law passed with broad support, including from the opposition party, even though some urged caution.