Jackson, an appointee of President Barack Obama, instructed the White House to preserve “all records of efforts by White House or other executive branch officials to return, ‘claw back,’ ’lock down’ or recall White House records” about dealings with foreign officials.

The order came in a lawsuit filed in May by the watchdog group Citizens for Responsibility and Ethics in Washington, as well as two history-focused organizations: the National Security Archive and the Society for the History of American Foreign Relations. The suit alleged that the White House was failing to maintain and putting at risk records of presidential actions required to be documented by the Presidential Records Act.

While the suit predated the Ukraine controversy, lawyers pressing the case asked Jackson on Tuesday for a temporary restraining order, citing reports that records of Trump’s phone calls with the president of Ukraine and some other leaders had been removed from the usual database at the White House and moved to another one not typically used for those calls.

Justice Department lawyers said in a court filing Wednesday that the White House had already taken steps to secure many of the records the plaintiffs expressed concern about. The filing also suggested that in response to the request for a restraining order, White House lawyers broadened an existing instruction to preserve records of Trump’s foreign interactions.

Justice Department attorneys said those actions met a request by the judge to “moot” the groups’ request for a restraining order.

Jackson appeared to agree. After a telephone conference Wednesday, she issued a notice saying that the request for a restraining order was denied because it was moot in light of the government’s assurances. However, the following day, she issued an order insisting that six categories of records related to the suit be preserved.

Jackson’s decision to issue an order despite the pledge to the court to maintain the records is rather unusual. In most instances, judges simply note such a pledge and say they assume that the parties involved will abide by it. The order means anyone destroying White House records it covers could be subject to sanction or even criminal charge for contempt of court.

Another unusual aspect of the judge’s order is that it appears to cover Trump directly. Whether judges can or should issue injunctions against the president directly, as opposed to members of his staff, is a matter of some legal controversy. The order Jackson issued Thursday seems deliberately worded to avoid explicitly mentioning the president, but it applies to the “defendants” in the lawsuit of which there are only two: the Executive Office of the President and President Donald J. Trump.

Spokespeople for the White House and the Justice Department declined to comment on the order. In a court filing this week, government lawyers said they believe the suit lacks legal merit. They filed a motion to dismiss the suit back in August, but Jackson has yet to act on it.