A former FBI bomb technician who later worked as a contractor for the bureau has agreed to plead guilty to disclosing national defense information to the Associated Press about a disrupted terrorist plot to bring down a civilian airliner headed for the United States, the Justice Department said Monday.

Officials described the disclosure as one of the most serious national security leaks in history, saying it came in the middle of a sensitive intelligence operation. The case led to the Justice Department’s controversial decision to secretly subpoena two months’ worth of phone records from the Associated Press.

Donald John Sachtleben, 55, of Carmel, Ind., provided information to an AP reporter about the disruption of the plot by the Yemen-based terrorist organization al-Qaeda in the Arabian Peninsula. Sachtleben also told the news agency that the United States had recovered a bomb during the investigation of the April 2012 plot and that it was being examined at an FBI lab in Quantico where he sometimes worked, according to Justice Department officials and court documents filed Monday in the U.S. District Court for the Southern District of Indiana.

Administration officials and others later described the device as extremely difficult to detect and said it was built by the Yemeni group’s master bombmaker, Ibrahim Hassan al-Asiri.

“This unauthorized and unjustifiable disclosure severely jeopardized national security and put lives at risk,” Deputy Attorney General James M. Cole said. “To keep the country safe, the department must enforce the law against such critical and dangerous leaks, while respecting the important role of the press under the department’s media guidelines and any shield law enacted by Congress.”

Sachtleben apologized for his actions in a statement released by his attorney, Larry A. Mackey.

“I am deeply sorry for my actions,” Sachtleben said. “While I never intended harm to the United States or to any individuals, I do not make excuses for myself. I understand and accept that today’s filings start the process of paying the full consequences of my misconduct, and I know that the justice system I once served so proudly will have its say.”

Last year, in an unrelated investigation, Sachtleben agreed to plead guilty to charges of possessing and distributing child pornography.

The plea agreements call for Sachtleben to be sentenced to a total of 140 months in prison, including a 43-month term for the national security offenses and a consecutive 97-month term for the child pornography charges, which were filed in May 2012.

In a broad federal investigation, Justice officials secretly obtained records from more than 20 cellular, office and home telephone lines assigned to the Associated Press and its journalists as part of a year-long investigation into the disclosure.

A spokesman for the Associated Press declined to comment on the charges against Sachtleben.

“We never comment on our sources,” said Paul Colford, director of media relations for the organization.

The original story infuriated the Obama administration, and some Republicans in Congress accused the president of leaking information about the foiled plot to help his reelection campaign. In June 2012, Attorney General Eric H. Holder Jr. appointed the U.S. attorney for the District of Columbia, Ronald C. Machen Jr.,to investigate the possible leak of classified information.

“Fifteen months ago, we were given the task of uncovering who had threatened a sensitive intelligence operation and endangered lives by illegally disclosing classified information relating to a disrupted al-Qaeda suicide bomb plot,” Machen said Monday. “After unprecedented investigative efforts by prosecutors and FBI agents and analysts, today Donald Sachtleben has been charged with this egregious betrayal of our national security.”

Valerie Parlave, the assistant director in charge of the FBI’s Washington Field Office, said investigators conducted more than 500 interviews and analyzed telephone records obtained under subpoenas.

In May, AP President Gary B. Pruitt revealed that as part of its leak investigation, the Justice Department had secretly obtained two months’ worth of the telephone records of journalists working in Washington, New York and Hartford, Conn.

The uproar over the aggressive investigation — and over an unrelated case in which Fox News reporter James Rosen was called a possible “co-conspirator” in a crime in order to obtain a search warrant for his records — led Holder to convene a series of private meetings with journalists.

Press advocates have said the Justice Department’s forceful pursuit of leak investigations infringes on press freedom. In July, Holder announced tighter controls on prosecutors’ ability to subpoena the phone and other records of journalists.

Sachtleben worked for the FBI from 1983 through 2008. As a special agent bomb technician, he was assigned to many major terrorism cases, including the Oklahoma City bombing, the 1993 World Trade Center bombing, the Unabomber attacks, the U.S. Embassy bombings in East Africa, the USS Cole bombing and the attacks of Sept. 11, 2001.

In 2008, Sachtleben retired from the bureau and was rehired as a contractor. He maintained his top-secret security clearance, had regular access to classified and national defense information, and routinely visited the FBI lab in Quantico, according to court papers.

Shortly before the leak on May 2, 2012, to the Associated Press, Sachtleben became the focus of a child pornography investigation. On May 11, 2012, as part of that investigation, the FBI executed a search warrant and seized his laptop computer. It held about 30 images and video files containing child pornography, according to court documents.

Sachtleben had developed a “source-reporter relationship” with the AP reporter since 2009, when he was a contractor with the FBI’s National Improvised Explosive Familiarization training program, according to court documents signed by Justice officials and Sachtleben and his attorney.

He was identified as a suspect in the leak case after the toll records for the reporter’s phone numbers were obtained through a subpoena and compared with other evidence collected during the investigation.

That allowed investigators to obtain a warrant authorizing a more exhaustive search of Sachtleben’s cellphone, computer and other electronic equipment, which were already in the possession of federal agents because of the child pornography investigation, according to Justice Department officials. With that warrant, agents were able to obtain cellphone text messages between the reporter and Sachtleben.

Julie Tate contributed to this report.