STOCKHOLM — It was supposed to be an adventurous motorcycle journey through Africa. Johan Gustafsson, then a 36-year-old engineer, set off with a friend to see the continent, “not just read about it in books,” he later said. His biggest concern was traffic accidents.

Twenty-four hours after he arrived in Timbuktu, Mali, Mr. Gustafsson was taken hostage from his hotel at gunpoint. He and two other tourists were herded into the back of a pickup truck. A fourth man, a German tourist, resisted and was shot dead on the spot.

That was Nov. 25, 2011, the beginning of an almost six-year ordeal for Mr. Gustafsson, who was held for ransom in the Sahara by Al Qaeda in the Islamic Maghreb, or AQIM, the North African branch of Al Qaeda, until he was freed this year.

On June 26, Mr. Gustafsson, now 42, returned to Sweden, the second of the “Timbuktu Three” to be freed. French Special Forces rescued one hostage, Sjaak Rijke, a Dutch citizen, in April 2015. The other, Stephen McGown, a South African, was released in August.