A 31-year-old man from Alexandria, Minn., shot and killed Tuesday by two undercover agents had charged at them with a knife, authorities said Thursday.

The shooting that killed Adam Jo Klimek occurred about 2:15 p.m. at a house on the 300 block of 4th Avenue E. in Alexandria as agents from the Minnesota Bureau of Criminal Apprehension (BCA) conducted an undercover operation involving the solicitation of minors.

According to a statement released Thursday by St. Paul police, who are investigating the shooting at the BCA's request:

Klimek entered the house and was told by officers that he was under arrest. At that point, he "brandished a knife and charged at three agents." Two agents, identified by police as Beth Eilers and Dustin Van der Hagen, fired their handguns, striking Klimek. After Klimek fell, the agents administered first aid and called paramedics, who pronounced him dead at the scene.

Klimek was on probation after pleading guilty in 2014 to one count of prostitution with someone under age 13. According to court records in that case, Klimek admitted in Olmsted County Court that he hired a prostitute on Craigslist and intended to have sex, but did not. He said he didn't know she was 12, but that mistake of age was not a defense. A prison sentence was stayed and he was sentenced to 20 years of probation, 90 days on work release and ordered to register as a sex offender.

Eilers has been a BCA special agent for nine years; Van der Hagen has been a special agent in training for one month. He previously worked for 11 years with the Willmar Police Department, according to the BCA. Neither agent has any disciplinary actions or complaints in their BCA files.

St. Paul police spokesman Steve Linders said Thursday that investigators from his department have traveled to Alexandria to interview witnesses and review evidence in hopes of determining what led to the shooting. Their findings will be turned over to the Douglas County attorney's office for review.

Meanwhile, the Anoka County medical examiner's office is conducting an autopsy to determine the exact cause of death.

The Associated Press contributed to this report.