The 50-year-old identified as Abdul Hamid S. was arrested in western Germany, federal prosecutors said in a statement.
“The accused was a language evaluator and cultural issues adviser of the German armed forces. In this capacity, he is believed to have passed on information to an Iranian intelligence service,” they added.
According to Spiegel Online, he is suspected of working for Iranian secret services for several years.
While working for the German army, he had access to highly sensitive information including on troop deployment in Afghanistan, the report added.
Previous cases of infiltration by a foreign agency have sparked outrage and shock in Germany.
In 2016, Markus Reichel, himself a former intelligence agent for Germany, was convicted for spying for both the CIA and the Russian secret service.
He admitted handing over “scores of documents and internal information” to the CIA, including papers detailing Germany's counter-espionage strategies.
Reichel also delivered three classified documents to the Russians.
In 2011, Germany jailed a married couple for spying for the Russian secret services for more than 20 years.
The pair, identified only by the code names Andreas and Heidrun Anschlag, were planted in the former West Germany from 1988 by the Soviet Union's KGB and later worked for its successor the SVR.
The couple had obtained NATO and EU political and military secrets, focused especially on the relationship of NATO and the EU with eastern European and central Asian countries.