Charlie Savage / New York Times News Service

WASHINGTON — A former FBI agent has agreed to plead guilty to leaking classified information to The Associated Press about a foiled bomb plot in Yemen last year, the Justice Department announced Monday. In a twist, the former agent had been under investigation in a separate child pornography case, and he has also agreed to a guilty plea in it.

Federal investigators said they were able to identify the man, Donald Sachtleben, a former bomb technician, as a suspect in the leak case only after secretly obtaining the AP reporters’ phone logs, a move that set off an uproar among journalists and members of Congress of both parties when it was disclosed in May.

Sachtleben, 55, of Carmel, Ind., who was an FBI agent from 1983 until 2008, has agreed to serve 43 months in prison for the leak, the Justice Department said. His case is the eighth leak-related prosecution under the Obama administration. Only three such cases were prosecuted under all previous presidents.

Sachtleben has separately agreed to plead guilty and serve 97 months in the pornography case. His total sentence, should a judge accept the plea deal, is 140 months, or nearly 12 years. The 43 months for leak-related offenses is the longest ever imposed by a federal civilian court in such a case, although a military judge last month sentenced Chelsea Manning, formerly known as Pfc. Bradley Manning, to 35 years in prison for leaking archives of documents to WikiLeaks.