Neil Cohen, 59, acknowledged viewing and printing images meant for sexual gratification from a computer in his former legislative office. He left at least one image at a receptionist's desk, leading to the investigation and charges.

Cohen pleaded guilty to endangering the welfare of a child by distributing child pornography and could be sent to state prison for five years when he is sentenced on July 12.

Under terms of a plea agreement, Cohen will have to register as a sex offender under Megan's law and be subject to lifetime supervision by the Parole Board when he is released from prison. He agreed never to seek public office again and to pay at least $1,800 in fines. His use of social networking Web sites also will be restricted.

Cohen, an attorney who now lives in Paramus, likely will be disbarred.

Cohen and his lawyers left court without commenting. Prosecutors also declined to comment.

Looking gaunt and sporting a full beard, Cohen answered the judge's questions succinctly in a low, barely audible voice.

"That's correct, sir," Cohen said when asked if he intended to plead guilty.

Cohen acknowledged being on medications but told the judge the drugs did not impair his judgment.

In exchange for the guilty plea, other charges against the former assemblyman were dropped. Cohen faced up to 30 years in prison if convicted of official misconduct and child pornography charges.

"Mr. Cohen, through his actions in viewing and distributing child pornography, linked himself to an abhorrent industry that preys on children," Attorney General Paula Dow said in a statement. "Every single person who willingly enters the criminal network of suppliers and users of child pornography becomes part of the tragic exploitation and abuse of the innocent victims."

Cohen was accused of using state computers in his Union County legislative office to view, print and duplicate images of underage girls. The staff member who discovered the photos told the two lawmakers who shared the office with Cohen, Sen. Ray Lesniak and Assemblyman Joe Cryan. They reported Cohen to state authorities in July 2008.

A week later, Cohen resigned, ending a 17-year career in the Legislature. He then checked himself into a psychiatric hospital.