The federal judge was irritated.

“Who is this Patel guy?” he asked prosecutors at a meeting in his chambers at the federal courthouse in Houston to discuss a terrorism case with them and a lawyer for the defendant.

Ted Imperato, an assistant U.S. attorney in the Houston office, explained that Patel was, in fact, Kashyap Patel, a prosecutor in the Justice Department’s National Security Division in Washington, which oversees terrorism cases. And he noted that he had allowed Patel to use his account login so the Washingtonian could give notice that he would be involved.

“Don’t let those sons of bitches use your account,” said U.S. District Judge Lynn Nettleton Hughes.

“And put that in the record,” he added for the court reporter.

What followed last month — memorialized in a transcript that was unsealed at the request of The Washington Post — was a Texas-size bollocking over proper attire, wasting taxpayer money and spying for the bureaucrats in Washington.

Patel was summarily tossed from the judge’s chambers and Hughes — if anyone doubted his 10-gallon grumpiness — subsequently issued an “Order on Ineptitude” to berate the “pretentious lawyers” at “Main Justice.”

[Read: How a federal judge in Texas berated the Justice Department]

The episode has left those very lawyers in the Justice Department fuming at the rough handling of their colleague, according to a person who declined to speak publicly for fear of adding more fuel to the feud.

Patel declined to comment, as did a Justice Department spokesman who also wouldn’t say whether Patel is still involved with the prosecution.

The case that caused the judicial kerfuffle involves Omar Faraj Saeed al-Hardan, 24, a Palestinian born in Iraq, who was charged with attempting to provide material support to the Islamic State.

The prosecution got off to a bad start almost immediately. At a detention hearing last month, a Department of Homeland Security agent testified that Hardan had wanted to blow up a pair of Houston malls.

Prosecutors subsequently had to correct that testimony and the FBI later issued an embarrassing news release saying that although Hardan had discussed future targets, “there was never any active or planned plot targeting a specific location in Houston or elsewhere.”

The detention hearing also didn’t pass without Hughes counting what he considered 11 nonessential government employees in his courtroom, according to an account of the proceeding.

[Read transcript: How a federal judge in Texas berated a federal prosecutor]

Hughes, 74, is something of a maverick, known for courtroom outbursts and comments about race that have led some plaintiffs to call on him to recuse himself. At a pretrial conference in a discrimination case involving an Indian American, for instance, he discussed “Adolf Hitler’s use of swastikas, the origin of Caucasians and the futility of diversity programs at universities,” according to a report in the Texas Observer.

The plaintiff, Jitendra Shah, asked an appeals court to remove Hughes for bias. In his defense, Hughes wrote that “the court’s asserted hostility to Indians would surprise its immigrant or first-generation Indian doctors, friends, law clerk, and interns.”

The appeals court dismissed Shah’s petition.

“He has a contrarian streak,” said Brian Owsley, a former magistrate judge in the Southern District of Texas.

In another recent terrorism case in Houston, prosecutors asked Hughes to overturn a magistrate’s decision to place under house arrest a terrorism suspect who had headed to Syria to fight but returned to the United States.

“A man devoted to become a martyr would not turn around,” said Hughes, who upheld the magistrate’s decision.

Other remarks at the hearing also raised eyebrows. After a prosecutor mentioned the killings of two American journalists, James Foley and Steven Sotloff, Hughes responded, “The Americans went into territory [the Islamic State] controlled. No. An American who voluntarily subjects himself to the authority of beheading theological fanatical murderers, that is not against America any more than somebody who robs you in Paris.”

Patel arrived in Houston on Jan. 28 after flying from Tajikstan via London. As soon as he entered the judge’s chambers, Hughes pounced.

“What is your role in this?” he asked.

“I’m a member of the trial team from the counterterrorism section,” Patel responded.

“You’re not a member of the trial team,” the judge said. “It’s been going on for a month or so and you haven’t been here, have you?”

Hughes was just getting warmed up.

“And where is your tie? Where is your suit?” he asked.

“My apologies, sir,” Patel replied. “I had to change my flight overnight. I was overseas for work, and I just flew in an hour ago, and I didn’t have all my . . .”

“What did you wear on the plane?” the judge pressed.

“I wore this, sir” he explained. “This is all I had.”

“Why didn’t you wear a suit?”

“I didn’t have one with me overseas. I just flew in from Central Asia, sir, about an hour ago.”

Hughes then told Patel to go get his passport so he could examine it. He apparently wanted to see the stamps that would verify that Patel had been in Tajikistan.

“If you want to be a lawyer, dress like a lawyer,” the judge said.

“I will, sir,” Patel said.

“Act like a lawyer.”

Hughes wasn’t finished. He wanted to know how Patel would contribute to the case “other than being a spy for a bunch of other people.”

He also noted that plenty of government lawyers were in the nearby offices of the U.S. attorney.

“So, what is the utility to me and to the people of America to have you fly down here at their expense, eat at their expense and stay at their expense when there are plenty of capable people over there, in this room plus over there?” Hughes said “You’re just one more nonessential employee from Washington. . . . You don’t add a bit of value, do you?”

And with that, he told Patel, “You may be excused.”

When word of the hearing reached Patel’s bosses in Washington, they apparently tried to get a transcript of the session, but with some difficulty. Their efforts provoked another rebuke from Hughes, who issued his “Order on Ineptitude” — now being passed around legal circles like a deliciously illicit piece of literature.

Hughes thundered, “If the pretentious lawyers from ‘main’ Justice knew what they were doing — or had the humility to ask for help from the United States Attorney for the Southern District of Texas — it would not have taken three days, seven telephone calls, three voicemail messages, and one snippy electronic message for them to indirectly ask the court for assistance in ordering a transcript.”

Indeed, it wasn’t hard to get one. With the help of no lawyers, this reporter called the judge’s secretary and asked that the transcript be unsealed. The next day, the judge issued an order to do so, but with some redactions, and a copy was promptly provided to The Post.

Ellen Nakashima and Julie Tate contributed to this report.