Prime Minister Malcolm Turnbull flagged the move in July, prompted by the frequency and severity of attacks around the world.
It will allow Attorney-General George Brandis to apply for an extension 12 months before a sentence expires.
For this to happen, the Supreme Court would need to be satisfied that the offender poses an unacceptable risk of committing a serious terrorism offence if released into the community.
"This bill strengthens the ability of our security agencies to continue to detain somebody if they've committed serious terrorism offences... and they have not been rehabilitated," Justice Minister Michael Keenan told parliament.
"We are not going to allow people who haven't been rehabilitated in prison to be released and then go on to harm our fellow Australians."
The law is similar to arrangements already in place for sex offenders and extremely violent individuals in some states. There would be regular reviews and reassessments.
The passing of the High Risk Terrorist Offenders Bill was opposed by the Greens and Liberal Democrat David Leyonhjelm, but had enough support to pass through the upper house Senate.
"We should not be able to effectively impose life imprisonment on someone who was not originally sentenced to life imprisonment," he said.
Keenan said that since September 2014 when Australia's terror alert level was lifted to high, 55 people had been charged as a result of 24 counter-terrorism operations.
"Currently we have 40 people before the courts for terrorism-related offences," he added.
"We've also had four attacks in Australia during this period, and because of the great work of our counter-terrorism authorities, we have stopped a further 11 attacks."
(This story has not been edited by NDTV staff and is auto-generated from a syndicated feed.)