James Comey, the FBI director at the center of a political firestorm over his decision to resume the investigation into Hillary Clinton's emails, was once a figure in the misguided and leak-prone terrorism investigation of an Oregon man.

Comey was deputy U.S. attorney general in 2004 when the federal government zeroed in on Brandon Mayfield, a Portland-area lawyer and Muslim convert who was erroneously linked to a deadly terror attack in Madrid, Spain. The government's mistake prompted the FBI to issue an extraordinary apology to Mayfield.

Numerous leaks about Mayfield's alleged involvement in the bombing prompted U.S. District Judge Robert Jones to issue a gag order in the case. The judge personally delivered a copy of that order to Comey at the time.

The episode is detailed in a 2008 book Mayfield's lawyer, Steve Wax, wrote about the case.

Wax recounted a conversation he had with the judge describing what happened:

The judge, frustrated by the government's leaks, called Comey into his chambers at the federal courthouse in Portland, handed Comey the order and told him to give it to his boss, then-U.S. Attorney General John Ashcroft.

Comey was apparently offended and asked whether the judge was "impugning the attorney general's integrity," Wax wrote.

"He told me that he had warned Comey that the leaks were going to stop and that he would hold the attorney general personally responsible if they did not," Wax wrote in "Kafka Comes to America: Fighting for Justice in the War on Terror."

Now head of the FBI, Comey jolted the race for the White House with his letter to Congress 11 days before the election informing lawmakers of newfound Clinton emails.

He didn't say who sent or received the emails, whether the emails include duplicates of messages already reviewed or whether the emails contain any classified information.

Former Attorney General Eric Holder and dozens of other former federal prosecutors signed a letter critical of Comey's actions. That letter obtained by The Associated Press contends that Comey deviated from U.S. Justice Department policy when he alerted Congress to the discovery of new emails potentially related to the investigation of Clinton's use of a private email server when she was secretary of state.

Justice Department officials are instructed not to discuss ongoing investigations and to "exercise heightened restraint near the time of a primary or general election," to avoid the appearance of prosecutorial influence in the electoral process, according to the letter.

-- Noelle Crombie

503-276-7184; @noellecrombie

The Associated Press contributed to this report.