In exchange, prosecutors agreed to dismiss six other charges during Tuesday's hearing.
The 52-year-old Becker pleaded guilty to attempted sexual assault of a child under 16 and child enticement. He faces up to 45 years in prison when he's sentenced March 3.
Defense attorney Patrick Cafferty declined comment until after Becker's sentencing hearing.
Becker was arrested at a shopping center on Jan. 13 in a sting operation after authorities said he was involved in explicit Internet chats with a state agent posing as a 14-year-old girl.
Becker was charged Jan. 15 and resigned as mayor five days later.