The U.S. attorney in New Orleans, who built a reputation for prosecuting public officials, resigned Thursday in the midst of a federal investigation into two top deputies who used the Internet to anonymously attack people their office was investigating.

Jim Letten, the U.S. attorney for the Eastern District of Louisiana, was appointed by George W. Bush in 2001 and is the longest-serving U.S. attorney in the country.

Resignations of U.S. attorneys under a cloud of scandal are rare. In an unusual step, Deputy Attorney General James Cole traveled to New Orleans on Thursday and informed the district’s federal judges that the Justice Department had appointed a career prosecutor to investigate the allegations of misconduct in Letten’s office.

Letten’s resignation, effective Tuesday, comes eight months into a scandal that sparked the Justice Department investigation of his top deputy and a second veteran prosecutor in connection with anonymous online criticism of a man whose company is the target of a federal inquiry.

The two prosecutors, former first assistant U.S. attorney Jan Mann and former assistant U.S. attorney Sal Perricone, acknowledged using aliases to post comments on the Web site of the Times-Picayune newspaper. The comments were highly critical of Fred Heebe, the owner of a local landfill that was under federal investigation, according to court papers. Perricone, a member of Letten’s inner circle, resigned, and Mann was demoted.

U.S. Attorney Jim Letten speaks at a 2011 news conference in New Orleans. Letten announced Thursday that he is resigning while the Justice Department investigates alleged misconduct by two of the top deputies in his New Orleans office. (Gerald Herbert/AP)

The Justice Department’s Office of Professional Responsibility is investigating the episode, and last week a federal judge increased the pressure on Letten by calling for an independent counsel to probe the matter.

The judge, Kurt D. Engelhardt, also called for the department to investigate leaks of grand jury information to the media by prosecutors in the high-profile Danziger Bridge case, in which New Orleans police officers shot innocent city residents after Hurricane Katrina in 2005 and then tried to cover it up.

In a statement Thursday, Attorney General Eric H. Holder Jr. praised Letten’s service and announced the appointment of an interim U.S. attorney, Dana J. Boente, a senior prosecutor in the Eastern District of Virginia.

“As the longest-serving U.S. Attorney in the country today, U.S. Attorney Jim Letten has demonstrated an unwavering commitment to the people of his district and the nation by working tirelessly to make their communities safer through reducing violent crime, fighting public corruption and protecting their civil rights,” Holder said in a statement.

Through a spokeswoman, Holder declined to comment on the controversy.

Letten said he would stay on briefly to help the office with the transition to new leadership.

The Internet scandal came to light in March when Heebe filed a defamation lawsuit against Perricone. Heebe had been attacked repeatedly by an anonymous critic on the Times-Picayune Web site, and he hired a former FBI agent to track down the critic.

It was not just any former agent. He hired James R. Fitzgerald, whose work as a forensic linguist contributed to the 1996 arrest of “Unabomber” Ted Ka­czynski, who had eluded the FBI for 17 years.

When Fitzgerald analyzed the postings, he found that the writer was not just any blogger. The linguistic trail led to Perricone, who was involved in the investigation of Heebe’s company.

Perricone admitted posting the derogatory information under an alias and making similar online attacks on lawyers, defendants, police officials and judges. He remains under investigation by the Justice Department.

This fall, Heebe filed a separate lawsuit against Mann, then the second-ranking prosecutor in Letten’s office. The suit accused her of using an alias to post critical comments about Heebe on the newspaper Web site, in some cases coordinating her comments with Perricone.

Mann also remains under investigation by the Justice Department. Letten said in a recent court filing that Mann admitted writing the critical comments.

A spokesman for the U.S. attorney’s office declined to comment about Mann and referred calls to a spokesman for the Justice Department, who also declined to comment.

Perricone’s attorney, E. John Litchfield, said his client acknowledged the online postings after Heebe’s lawsuit was filed. He said Perricone did not lie or violate any laws.

Because of the online controversy, the U.S. attorney’s office withdrew from the landfill case, which has been taken over by Justice Department lawyers from Washington.

Letten is the second U.S. attorney to resign amid a scandal since President Obama took office. Last year, the U.S. attorney in Arizona resigned in the wake of a botched gun-running investigation.

Federal officials say proving prosecutorial misconduct can be difficult. But papers filed in ­Heebe’s­ lawsuit against Perricone indicate that Fitzgerald turned up convincing evidence.

From August 2011 until March 2012, an anonymous blogger posted 598 comments, many of which disparaged Heebe, who was once a candidate to be U.S. attorney. The blogger called himself “Henry L. Mencken1951.” Among his entries was one that read, “Heebe comes from a long line of corruptors.”

According to court papers, Fitzgerald found “highly distinctive” and “eerily similar” language in the online comments and a nine-page legal pleading co-authored by Perricone. Based on punctuation, alliteration and archaic words such as “dubiety” and “redoubt,” Fitzgerald concluded that a comparison of the two documents “strongly indicates” that Perricone and the commenter were the same person, the lawsuit said.

Fitzgerald declined to discuss the New Orleans case, but in an interview he compared his work to the analysis of DNA.

“Like DNA, language is composed of many small individual parts, letters, syllables, words, phrases and clauses, and it’s how they’re strung together and how they’re punctuated that can be very valuable direct evidence linking one person to one communication,” Fitzgerald said.

The evidence led Perricone to admit that he posted the comments using an online alias that combined the name of the famous Baltimore Sun muckraker H.L. Mencken and the year that Perricone was born, 1951.

Sen. Mary L. Landrieu (D-La.) praised Letten’s long service, but she said that the revelations of prosecutorial wrongdoing were troubling and that the time had come for a change.

“Today’s personnel changes within the U.S. Attorney’s Office for the Eastern District are a necessary step toward public trust in an institution charged with fighting corruption and keeping the people of the Eastern District safe,” Landrieu said in a statement.

Julie Tate contributed to this report.