WASHINGTON — The top two officials overseeing the military commissions court at the Guantánamo Bay wartime prison were fired last month because they were difficult to work with, not because of the officials’ legal actions, Secretary of Defense Jim Mattis and the Pentagon’s general counsel have told a judge.

The court filing from top Pentagon officials was the first explanation for the abrupt ouster of the officials, Harvey Rishikof, who had been serving as the so-called convening authority over the tribunals system, and Gary Brown, his legal adviser. In a separate joint declaration to the judge, the two men said they were given no warning of any management problems and no explanation when they were suddenly fired.

The account from top Pentagon officials was an apparent response to accusations that the lawyers’ work prompted their dismissals. After the firings, lawyers representing detainees charged with aiding the attacks on Sept. 11, 2001, voiced suspicion that they might have been ousted because of a policy disagreement over whether their actions affected detainee defendants. Attempts by superiors to influence the handling of a case are forbidden as unlawful command influence.