The onetime police chief in Walnut Grove, one of Minnesota’s most famous towns, has admitted to trying to buy sex from someone he believed was a teenage girl.

Michael R. Zeug, 46, pleaded guilty to attempting to hire a minor for sex, a gross mis­demeanor, in June 2017.

Zeug was given a jail term of one year with all but 100 days stayed and credit for four days served. He was also fined $1,000 and ordered to undergo a psychological examination and abide by any prescribed therapy. Sentencing is scheduled for Sept. 21.

Through Operation Guardian Angel, conducted by a regional drug task force and a Washington County human trafficking task force, law enforcement officers posted online ads last year on Backpage.com and Craigslist.org to identify potential suspects pursuing minors for sex.

Walnut Grove is a town of 800 in southwestern Minnesota whose long-running fame stems from the “Little House on the Prairie” books written by Laura Ingalls Wilder. One of those books, “On the Banks of Plum Creek,” is set in Walnut Grove.

Zeug sought to buy sex from someone he believed was a 17-year-old girl, but he actually was communicating with an undercover agent with the federal Department of Homeland Security.

The husband and father arranged a meeting outside a house in Redwood Falls, asked for nude photos and wanted her to flash her breasts to assure him she was not in law enforcement, the charging document read.

The police chief circled the house several times and then parked nearby, the complaint said. He was arrested by members of the sting operation.

The city suspended Zeug without pay soon after his arrest, and he resigned in May.