SEOUL, South Korea — Kim Dong-chul, an American businessman in Rason, a North Korean special economic zone near the border with Russia, was leaving a local government office on Oct. 2, 2015, when he was stopped by a 34-year-old army veteran he had hired as a secret informant.

“Chairman Kim, here is the information you wanted,” the man said, tossing a yellow envelope into Mr. Kim’s car, before rushing away. In the envelope were a computer memory stick, documents and photographs of a ship docked at a nearby port. Mr. Kim hadn’t gone several yards before his car was stopped again by an officer from the Ministry of State Security, the North’s infamous secret police.

Mr. Kim knew he had just been set up, but it was too late.

It was the beginning of a 31-month incarceration in North Korea that included torture, a conviction on espionage charges and forced labor in a prison camp. Mr. Kim was the longest-held American in North Korea when Secretary of State Mike Pompeo flew there in May last year. Mr. Pompeo returned home with Mr. Kim and two other American hostages, a triumphant moment for President Trump.

Now, in a memoir entitled “Border Rider,” published in South Korea in June, Mr. Kim, 65, recounts how he became a decorated foreign investor in North Korea, then spied for the Central Intelligence Agency and South Korea’s National Intelligence Service, and ended up as Prisoner No. 429.