The former mayor of Racine, Wis., has been sentenced to three years in prison after pleading guilty to two charges stemming from an Internet sex sting.

Fifty-two-year-old Gary Becker had faced up to more than 27 years in prison at his sentencing hearing Wednesday. He pleaded guilty in December to child enticement and attempted sexual assault of a child.

Judge Stephen Simanek said he was prepared to sentence Becker to probation but was alarmed to discover Becker purchased girls' underwear two weeks ago.

Prosecutors say Becker tried to arrange a sexual tryst last year with someone he thought was a 14-year-old girl. His online chat partner was really a state investigator.

Before sentencing, Becker apologized to his family and community.