The firing this week of a title-winning Minnesota high school tennis coach came after prosecutors say he mistakenly believed he was swapping sexually charged texts with a 15-year-old girl he thought was game for a liaison in a western Wisconsin apartment.

Instead, Kevin J. Rust, 59, showed up outside a Rice Lake apartment complex one night in late June only to be met by police, according to charges filed in Barron County District Court.

Rust, fired Wednesday from Benilde-St. Margaret High School as its boys tennis coach, was charged July 2 with use of a computer to facilitate a child sex crime, child enticement and attempted second-degree sexual assault of a child — all felonies.

His dismissal was announced in a statement from Benilde-St. Margaret President Adam Ehrmantraut.

The statement did not explain why the firing came more than 10 weeks after Rust was charged. Ehrmantraut and school spokeswoman Megan Brown did not make themselves available Thursday to field questions.

Barron County District Attorney Brian Wright said he learned only Thursday that Rust was a coach of minors.

Rust, of Minnetonka, was booked into jail upon being charged and later released on bond. His attorney, Joseph Tamburino, declined to address the allegations.

Rust, divorced since 2013, had coached at Benilde-St. Margaret’s for the past three years, joining the Catholic school after retiring from coaching at Lourdes High School in Rochester.

The State High School Tennis Coaches Association inducted Rust to its Hall of Fame in 2012, in honor of his 11 Class 1A team championships in 12 years with the Lourdes girls team.

“No one saw any of this coming,” said Matt Remick, owner of the Rochester Athletic Club, the private health club where Rust taught tennis before moving away several years ago. Remick said that as a junior high and high school student, he took lessons from Rust. “He would coach character as part of what makes you a successful tennis player. I never would have expected anything like this.”

According to the criminal complaint:

On June 14, Rust answered a listing on a personals ad website titled “younger lady looking for older.” Soon after, the undercover officer started receiving text messages from Rust.

On June 22, Rust said in a text to “Lyla” that he was 54 years old, and the officer replied that she was “almost 16 is that ok or no ...”

He replied: “Save yourself for me.”

When she asked whether he meant until she’s 18, Rust texted back: “No I mean now.”

The texting quickly turned overtly sexual, with Rust saying he wanted to have various forms of sex with her and she agreed. He also asked for nude photos of her.

A few days later, the two started arranging a meeting for a sexual encounter on June 28.

Rust showed up in Rice Lake that night and texted her that he was nervous about seeing what he suspected were law enforcement vehicles watching the area.

Putting that worry aside, Rust drove to the apartment complex and was arrested in the parking lot.

The undercover officer interviewed Rust, and he admitted thinking the texts were with a 15-year-old girl, but he denied he made the two-hour trip to have sex with “Lyla.”