BERLIN—German prosecutors are investigating possible spying activities in the association of Turkish mosques known as Ditib, the federal prosecutor’s office said Wednesday.

The investigation is focusing on whether some of Ditib’s Imams handed over information to Turkey about followers of the U.S.-based Turkish imam Fethullah Gulen, whom Turkish President Recep Tayyip Erdogan accuses of masterminding last year’s failed coup.

Ditib, Germany’s largest association of mosques, last week said in a local newspaper interview that some of its Imams in the country had handed over information about Mr. Gulen’s followers to the Ankara-based Presidency of Religious Affairs, also referred to as Diyanet, which reports to Turkey’s prime minister’s office. Some German newspapers had previously reported the spying allegations.

“The written request from Diyanet wasn’t directed at Ditib. Some Imams nevertheless wrongly followed it,” said Bekir Alboga, general secretary of Ditib, which manages some 900 mosques in Germany. “We deeply regret this mishap.”

Ole Schröder, parliamentary secretary for the interior ministry, told a German parliamentary session Wednesday the government was aware that Diyanet had prompted all Turkish embassies and religious representatives abroad in a letter last year to compile information about Mr. Gulen’s followers.