Published: Apr 04, 2013 3:16 PM EDT

TALLAHASSEE, Fla. (AP) - The Florida Supreme Court has ruled that the state can't hold a Venice man in sex offender detention because he had already finished his prison sentence by the time paperwork was filed.
    
The court ruled 5-2 in Larry Phillips' case on Thursday.
    
It said an individual must be in "lawful custody" when commitment proceedings are started. Phillips was in physical custody but his sentence had expired three months earlier.
    
Florida's "Jimmy Ryce Act" lets the state detain sex offenders even after they have completed prison if courts determine they are a danger to the community. They cannot be released until they've received treatment and a judge rules they no longer are a danger.
    
The law is named for a 9-year-old boy who was raped and murdered in Miami-Dade County.

(Copyright 2013 The Associated Press. All rights reserved. This material may not be published, broadcast, rewritten or redistributed.)