A mayor in southern Oregon is claiming “police entrapment” after he was arrested, accused of soliciting sex from a 14-year-old girl who turned out to be an undercover police officer working an online sex sting.

Kenneth Barrett, 71, was charged earlier this week with online sexual corruption of a child and unlawful possession of a firearm, according to court records. Police said additional charges are pending.

Kenneth Barrett. (Douglas County Sheriff’s Office)

Barrett claimed to multiple local media outlets stations Wednesday that he was deceived by the undercover police officer in the neighboring town of Myrtle Creek.

That same afternoon, just months into his first term as mayor, Barrett submitted his resignation.

“I believe that I’m a victim of entrapment,” he told the Oregonian. “I’ve been forced out of office. I’ve lost all my friends, and this has all been really devastating for me.”

It was not immediately clear whether Barrett has an attorney.

“I didn’t want to resign,” he told the News-Review of Roseburg, Ore., “but when the chief of police won’t shake your hand and when I have neighbors standing outside my house telling me to move, I think it would be in my best interest to resign.”

According to the News-Review, Barrett told reporters Wednesday morning that he had no plans to resign, declaring: “I have a deep desire to help the city.”

Hours later, though, he submitted his letter of resignation — apparently at the urging of city manager Mark Bauer.

“I asked him what his plans were, and he asked me what I thought,” Bauer told the News-Review. “I said it would be in his best interest and the best interest of the city for him to resign. He said he was thinking the same thing and that he would do that.”

Barrett was elected in November and took office in January. The city council president “will assume the role as mayor until the next election in November 2018,” the News-Review reported.

Myrtle Creek Police Chief Don Brown said Barrett and three other suspects were arrested in the online sting that began in late February to identify adults who were soliciting sex with children.

Brown said the other suspects are from Roseburg, Bakersfield, Calif., and Springfield, Ore. Amid media coverage of the sex sting, Brown said, officers lost two other potential suspects.

“These cases, as horrible as they are, often lead to human trafficking,” the chief said.

According to Brown, during the police operation Barrett told the undercover officer, who he seemed to believe was a 14-year-old girl, that in Thailand, a girl that age would be considered a mature woman.

Brown said suspects in these cases sometimes meet up with underage girls and take them elsewhere — and that’s how the girls can “end up in the trafficking world.”

On March 5, the police officer noticed that Barrett had written “hot” on a profile photo of a young girl on a Facebook account that the officer used to conduct undercover operations, according to court documents.

The officer engaged Barrett and the two started swapping messages.

When the girl told him that she was 14, Barrett allegedly replied, “I thought you were 21 oh well you are smart stay in school and work hard.” But as the two kept talking, he asked, “Do you enjoy texting older men?”

Over the next two weeks, Barrett called her a “full grown beautiful sexy young lady,” talked about “loving sex” and told her, “I love you girl,” according to the court records.

He allegedly asked, “Did you know that in Tiland (sic) you are an lady?”

“Later he asks her if she wants him to be a ‘bad boy or a grand dad,'” according to a probable cause affidavit. “He then says if he was her bad boy he would go to prison. Later in the conversation he posted, ‘are you still’ and a picture of cherries. She asked if he meant is she a virgin. He said, ‘Yes, are you?’ She said that she had messed around. He told her to be safe, smart and make it fun and special.”

In another note, Barrett allegedly asked her for ideas for things to do.

He told her the two could, “Fly to the north pole and visit Santa in his hot tub naked,” according to court records.

On March 18, “he went on to say he is going to get divorced, and that his marriage was never legal,” according to the affidavit. “She told him she didn’t care about age. He then discusses several different ways they could meet up. Later he said they would start a ‘Road trip to mars it is our job to populate the red planet just you and I building a new civilization in bed.’”

The two decided to meet on March 19, according to the court records.

When Barrett arrived at the agreed upon meeting spot Sunday night, he allegedly messaged her, “the bad boy is here.” Then law enforcement officers took him into custody.

Barrett was released Tuesday from the Douglas County jail and has since been speaking out about his ordeal.

“It was a stupid thing I did, but I’m a curious person,” Barrett told the Oregonian. “I can tell you that if I were really out trying to find someone to have intimate relations with, it wouldn’t have been with a kid.”

Barrett told CBS affiliate KPIC that he was trying to help a troubled girl and then he said he knew she was a police officer.

“They don’t know that I knew all along that I wasn’t talking to a 14-year-old girl; I’m talking to a police officer and I want to know who that officer is,” he told the station. “They gave the impression in their story that she had no father, her mother was mistreating her, her aunt came over — this whole thing was one big figment of their imagination and I give them the credit to think that they’re actually helping get predators off the street, but I’d like to know the list of people that they’ve entrapped in this.”

“If you read the transcript carefully,” he added, “you will see that I actually tried to convince her that I wanted to be a father to her. Then she says, ‘No, I don’t need a father.’”

When asked about his sexually explicit comments, Barrett told KPIC he was “totally wrong” to say those things.

“It was inappropriate,” he said. “I will have to go resign as mayor and apologize for bringing Winston into a very bad situation. And I am totally closing down all my social media as soon as I get my computer back.”

Then Barrett was asked whether he had done anything like this in the past.

“I have 5,000 people around the world on my Facebook and, from time to time, it gets inappropriate, but it’s women around the world. I know people who are economists in the Philippines. I have a lot of musician friends. And from time to time, the talk gets inappropriate in public,” he said.

But, Barrett added: “I’ve never done anything like this in my life.”

Read more:

A book about a dress-loving boy was supposed to teach kids acceptance — until lawmakers complained

A teacher allowed white students to ‘sell’ their black classmates in mock slave auction

Social workers allegedly failed to save a boy from abuse. Now they will face trial in his death.

‘Our family is heartbroken’: American killed in London attack was celebrating wedding anniversary