President Obama talks about national security Thursday at the National Defense University. (Pablo Martinez Monsivais/AP)

President Obama instructed Attorney General Eric H. Holder Jr. on Thursday to review Justice Department guidelines for leak investigations, meet with media organizations and report back to him by mid-July.

In a speech to the National Defense University, Obama addressed the uproar over his administration’s numerous leak investigations, saying he is “troubled” that the inquiries might “chill” investigative journalism. But he also emphasized that certain information must remain secret to protect national security.

“As commander in chief, I believe we must keep information secret that protects our operations and our people in the field,” Obama said. “To do so, we must enforce consequences for those who break the law and breach their commitment to protect classified information. But a free press is also essential for our democracy.”

The president’s call for a review of DOJ guidelines comes 10 days after it was disclosed that the Justice Department secretly obtained records from a two-month period for 20 telephone and cellular lines of journalists working for the Associated Press in Washington, New York and Hartford, Conn. The subpoena for the records was part of a year-long investigation of the disclosure of classified information about a failed al-Qaeda plot last year.

Court papers last week also disclosed that, in another leak investigation, the Justice Department obtained a search warrant for Fox News Channel reporter James Rosen’s personal e-mails and used security badge access records to track his comings and goings from the State Department.

President Obama’s speech on counterterrorism Thursday touched on drones, renewed efforts to close Guantanamo Bay, and was interrupted by a loud heckler. (Nicki Demarco/The Washington Post)

The disclosures provoked an outcry from media organizations and government secrecy groups. Representatives from news organizations said they welcome the opportunity to sit down with Holder.

“It’s been an astonishing couple of weeks because of the disclosures that have come out, not just about DOJ subpoena policy but also about its willingness to pursue journalists’ records through search warrants,” said Bruce Brown, executive director of the Reporters Committee for Freedom of the Press.

The committee, on behalf of more than four dozen news organizations, sent a letter to Holder and his deputy that rejected what it called “an overreaching dragnet for newsgathering materials” in the AP case. The letter demanded that the Justice Department destroy the phone records and disclose all other pending subpoenas related to the media.

Obama did not address the specific cases, but he said the administration’s focus in leak investigations should not be on reporters, but on government officials who release classified information.

“Journalists should not be at legal risk for doing their jobs,” he said. “Our focus must be on those who break the law.”

The president reiterated his call for Congress to pass media shield legislation to guard against what he called “government overreach.” The measure, introduced last week by Sen. Charles E. Schumer (D-N.Y.) and Rep. John Conyers Jr. (D-Mich.), would protect journalists from being compelled to testify about their confidential sources unless all other avenues are exhausted and exposure is in the public interest. A similar effort stalled in 2009.