(Reuters) -- Five Pakistani men have been arrested in Afghanistan in connection with the Taliban massacre of 134 schoolchildren in the Pakistani city of Peshawar last month, officials in both countries said Sunday. The five were detained last week after Pakistan sent a list of suspects to security services in the neighboring nation, said the officials, who asked they not to be named.

Taliban gunmen opened fire at the military-run school Dec. 16, killing nine staff members and the students, many of them the children of army personnel, in the country's bloodiest massacre in years.

"We are investigating whether the five detained are the ones wanted by Pakistan," one of the Afghan officials told Reuters.

Pakistan's Taliban is a separate organization from the Afghan Taliban, but both share the goals of toppling their respective governments and enforcing strict Islamist law across the region.

One of the Pakistani officials said another 20-25 people had been detained in Pakistan, but some had already been released.

A second Pakistani official said that talks were under way with the government for the transfer of the five prisoners in Afghanistan to Pakistan.

(Reporting by Hamid Shalizi and Jessica Donati in Kabul, and Katharine Houreld in Islamabad; Editing by Andrew Heavens)