A Long Island man is set to be released from his 25-year sentence for child sexual assault because an Eastern District judge found that state prosecutors withheld evidence at trial about a detective’s long history of allegedly coercing and falsifying confessions.

Artemio Castellanos, who was convicted in 2006 of a criminal sexual act and sexual abuse, both in the first degree, must be released from prison unless prosecutors give him a new trial within 90 days, Judge Margo Brodie ruled.