KABUL - A German engineer and four Afghans taken hostage in July were freed Wednesday in exchange for what an Afghan official described as five imprisoned criminals.

The German, Rudolf Blechschmidt, and the four Afghans were handed over by local elders to officials of Afghanistan's intelligence service in the Jaghato district of Wardak province, said the district chief, Mohammad Nahim.

Nahim at first said that six Taliban had been released in the swap.

He later said no Taliban had been released and that it was five criminals who had been freed.

One of the criminals was the father of the Taliban commander who had taken the German and Afghans, he said.

Nahim said the exchange had been arranged by Afghan elders. An Interior Ministry spokesman confirmed the release but said he didn't have further details about how it was arranged.

In Germany, Foreign Minister Frank-Walter Steinmeier confirmed that Blechschmidt had been freed, and the former captive told Spiegel magazine on his release that he was "doing well.''

"I'm just a little tired,'' he told the magazine in a short telephone interview posted on its website.

Blechschmidt had also talked with the German ambassador by telephone and confirmed he was safely in the custody of Afghan security forces, Steinmeier said in a statement.

"We are all pleased and relieved,'' Steinmeier said.

Blechschmidt arrived at the German Embassy in Kabul about three hours after he was released.

The release came two days after Blechschmidt appeared on a videotape, appealing to the Afghan and German governments to make a deal with the militants for his release before winter.

Blechschmidt said in the video that he was in poor health but that an Afghan doctor had helped him.

Blechschmidt is one of two German engineers and five Afghans taken hostage on July 18 in Wardak province in central Afghanistan. The other German was found dead of gunshot wounds on July 21, while one of the Afghans apparently managed to escape.

Four Red Cross employees were taken hostage by the Taliban on Sept. 27 while trying to win the German's release. The four were released in good health two days later.

On the video, Blechschmidt said the German Embassy had refused to engage in talks for a time, but that negotiations had restarted recently and that "we hope we will become free.''

Kidnappings by Taliban insurgents and criminal gangs have risen in Afghanistan in recent months. A string of high-profile kidnappings have led to ransom payments and prisoner releases, which some officials say has fuelled the rise in the abductions.

The governments of Italy and Afghanistan came under criticism earlier this year when five imprisoned rebels were freed in exchange for a kidnapped Italian journalist. At the time, Afghan President Hamid Karzai called the exchange a one-time deal.