The chief prosecutor spent Monday evening with a female prostitute in a central Stockholm hotel. A police squad, however, had been tipped off and was waiting for him in the staircase outside the room.
Officers were surprised to learn of the man's status while arresting him, as he was the prosecutor on duty to whom they should report the crime.
The man paid 1,500 kronor ($232) for the sex, according to the Expressen newspaper.
He had allegedly found the escort online, when "surfing around on his iPhone" during a train trip, during which he consumed half a bottle of wine and a beer.
"And then I did what I am suspected of - I went out into the staircase and the police arrested me there," the prosecutor told the Aftonbladet newspaper.
He has confessed to the crime, and his family has been notified.
"My wife will leave me and my children think I have behaved like a pig. Even my friends think the same," he told Expressen.
The man told Aftonbladet that in his experience as a prosecutor, he knew that the "stupidest thing" he could do was to lie.
"I have done what I've done, I'm standing with my pants down. The worst is what I have done to my family and friends," he said.
The arrested man explained that another prosecutor would take care of the case, and that he was unaware of his punishment, or when it would likely be determined.