WASHINGTON — A former F.B.I. 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 already 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 A.P. 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.

Mr. Sachtleben, 55, of Carmel, Ind., who was an F.B.I. agent from 1983 until 2008 and was later hired as a contractor, 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.

“This prosecution demonstrates our deep resolve to hold accountable anyone who would violate their solemn duty to protect our nation’s secrets, and to prevent future, potentially devastating leaks by those who would wantonly ignore their obligations to safeguard classified information,” said Ronald C. Machen Jr., the United States attorney for the District of Columbia.