WASHINGTON—Attorney General Merrick Garland sharply limited federal prosecutors’ ability to obtain records of reporters’ contacts when investigating government leaks of sensitive information on Monday, curtailing a longstanding practice that had drawn criticism in recent weeks, including from President Biden.

In a memo to federal prosecutors, Mr. Garland said the agency’s prior policies hadn’t properly weighed the national interest in protecting journalists from forced disclosure of their sources, saying they needed such protection “to apprise the American people of the workings of their government.”

Mr. Garland had promised he would bar prosecutors from seizing reporters’ information after recent disclosures that the Justice Department under former President Donald Trump secretly sought and obtained 2017 phone records from reporters at the Washington Post, CNN and the New York Times while trying to identify their sources. That sparked outrage among lawmakers, press-freedom organizations and Mr. Biden, who said he would no longer allow such tactics.

Mr. Garland, who as a federal judge took strong stands in support of reporters’ rights and First Amendment protections, told lawmakers in June that the new policy would be the “most protective of journalists’ ability to do their jobs in history.” He met with news executives to discuss their concerns at least twice in recent weeks.

The new policy includes exceptions for cases involving an agent of a foreign power or a member of a foreign terrorist organization, or when steps need to be taken to “prevent an imminent risk of death or serious bodily harm,” the memo said.

The three-page memo also said the department would support legislation codifying protections for journalists into law—going beyond the efforts of past administrations—and gave Deputy Attorney General Lisa Monaco responsibility for consulting with others to develop further regulations on the issue.

Such legislation hasn’t been a priority for lawmakers in recent years and would face an uncertain fate in Congress. Without becoming law, any rules made by the Justice Department under Mr. Garland could be reversed by a future administration.

SHARE YOUR THOUGHTS

Should prosecutors be allowed to seek reporters’ leak sources? Why or why not? Join the conversation below.

Press advocates applauded the move. “The attorney general has taken a necessary and momentous step to protect press freedom at a critical time,” said Bruce Brown, the executive director of the Reporters Committee for Freedom of the Press. “This historic new policy will ensure that journalists can do their job of informing the public without fear of federal government intrusion into their relationships with confidential sources,” Mr. Brown said.

Some former national-security prosecutors said while the existing guidelines already made it difficult to subpoena reporters’ records and provided for the tool as a last resort, they expected the new memo to further circumscribe such investigations.

“I think it will make leaks of classified information harder to investigate, but that was a trade off the department is willing to make in order to provide greater privacy protections to journalists and their sources,” said Kellen Dwyer, a former prosecutor who was deputy assistant attorney general in the Justice Department’s national-security division and is now at the law firm Alston & Bird.

Prosecutors for years have used subpoenas and court orders to obtain journalists’ records in leak investigations, often after exhausting other options for identifying suspects. Under the Obama administration, for example, the Justice Department used the tool for investigations involving reporting by the Associated Press and Fox News. Multiple former government employees and senior officials were prosecuted by the Obama Justice Department.

In one notable case in 2010, former Attorney General Eric Holder personally approved the seizure of phone records and personal emails of Fox News Channel reporter James Rosen, who reported on a secret government report about North Korea. An FBI search warrant request named Mr. Rosen as a possible criminal “co-conspirator.’’

In response to a backlash from press advocates and others, Mr. Holder in 2013 added new hurdles that prosecutors had to clear before they could obtain subpoenas and search warrants targeting reporters. The measures included requiring prosecutors to give a media organization notice before a subpoena could be issued to seize records, unless the attorney general certified that doing so would harm the investigation.

At the start of the Trump administration in 2017, then-Attorney General Jeff Sessions promised a crackdown on leakers of classified information and said the Justice Department would review policies on subpoenaing news organizations. Mr. Trump at the time had repeatedly complained about leaks related to contacts between Russia and figures in his 2016 election campaign and then-special counsel Robert Mueller’s investigation into those ties. In June 2021, a Treasury Department official was sentenced to six months in prison for leaking sensitive financial information about former Trump campaign chairman Paul Manafort and others.

Mr. Trump’s second attorney general, William Barr, continued the practice, directing a federal prosecutor from New Jersey to work on the roughly half-dozen leak cases he inherited.

Court documents unsealed last week show the Justice Department sought the records of three Washington Post reporters on Dec. 22, the day before Mr. Barr stepped down, in an effort to identify the sources in three stories. Prosecutors identified them by their publication dates: a May 2017 story detailing conversations between Mr. Trump’s adviser and son-in-law Jared Kushner and Sergey Kislyak, Russia’s ambassador to the U.S. at the time; a June 2017 report about the Obama administration’s struggles with Russian election interference; and a July 2017 story about conversations between Mr. Kislyak and Mr. Sessions, who had the discussions when he was a U.S. senator.

Prosecutors indicated in their application for a court order that they believed someone in Congress may have provided the details about Mr. Kislyak’s conversations to the newspaper.

The Trump Justice Department also seized communications records of some Democratic lawmakers in 2018, a revelation that drew outrage among Democrats. The lawmakers themselves weren’t targets of the investigation, The Wall Street Journal previously reported, and their records were obtained because they had been in contact with one or more aides whom prosecutors suspected of leaking classified information to the media.

Jamil N. Jaffer, who was a national-security official in the administration of George W. Bush, said the new policy could tie prosecutors’ hands in important investigations and ultimately could be viewed as an overreaction to Mr. Trump’s rhetoric. “This began in the Obama administration but took on a new character in the Trump administration, and we ought not to legislate based on the way the president publicly addressed these matters,” Mr. Jaffer said.

Senior Justice Department officials have long struggled with how hard prosecutors should push for reporters’ records in pursuit of the sources of leaks. For example, even as Mr. Sessions stepped up leak investigations, behind the scenes some department officials rejected a more aggressive posture, the Journal reported.

In 2017, for example, law-enforcement officials discussed with Mr. Sessions whether to soften a requirement that investigators exhaust other options for obtaining information in leak investigations before subpoenaing reporters’ records, the people said. Mr. Sessions asked his deputy, Rod Rosenstein, to review the policy, which officials ultimately declined to change.

Write to Sadie Gurman at sadie.gurman@wsj.com and Aruna Viswanatha at Aruna.Viswanatha@wsj.com