The Taliban has freed 23 local police officers it kidnapped during an assault in northeastern Afghanistan last week, a rare move by the insurgents who have long been known — and maligned — for killing prisoners.

The Taliban launched a large-scale attack on May 20, overrunning the district headquarters of Yamgan in Badakhshan province. The insurgents killed eight policemen and abducted 27 others, including three senior local officers.

In a statement e-mailed to news media late Monday, the Taliban said it released 23 of the captives through the mediation of local elders and as a gesture of “mercy” based on Islamic teachings.

The statement added that the prisoners pledged not to rejoin the government as a condition for their release.

The governor of Badakhshan, Shah Waliullah Adeeb, confirmed the releases and said influential elders were still trying to free the remaining prisoners.

“There was no ransom or any deal,” Adeeb said Tuesday by telephone. “In the past, the Taliban had killed a number of captives while releasing some, but this time they have killed none.”

The Taliban typically operates in small groups, attempting to undercut Afghan security forces even though its fighters are vastly outmanned countrywide.

The militants have been accused of killing prisoners of war, often in grotesque fashion, since being toppled from power in late 2001.

The release of the police officers comes amid rising anger over the alleged Taliban killings. There also has been a growing outcry among Afghans against the Taliban for deadly attacks on civilian targets and for killing scores of Afghan security forces each month as NATO and the United States continue to reduce their military presence.

The Taliban earlier this month announced its new annual spring offensive, vowing to target Afghan security forces, government officials and local contractors, as well as translators working for foreign troops.

Last week’s attack in Badakhshan, involving more than 200 fighters, appeared to be the largest Taliban assault since the declaration of the spring offensive.

A Taliban spokesman said the group’s struggle will continue as long as foreign troops remain in Afghanistan.