Updated

Just five months before the presidential election, the State Department is under fire in courtrooms over its delays in turning over government files related to Hillary Clinton's tenure as secretary of state.

In one case, the agency warned it needed a 27-month delay, until October 2018, to turn over emails from Clinton's former aides, and the judge in another case, a lawsuit by The Associated Press, wondered aloud whether the State Department might be deliberately delaying until after the election.

"We're now reaching a point where there's mounting frustration that this is a project where the State Department may be running out the clock," said U.S. District Court Judge Richard J. Leon. The judge said he was considering imposing penalties on the agency if it failed to meet the next set of deadlines he orders. Leon wondered aloud at one point whether he might impose penalties for again failing to deliver records on time. He mused about "a fine on a daily basis" or "incarceration."

"I can't send the marshals, obviously, out to bring in the documents, at least they wouldn't know where to go, probably," Leon said.

Secretary of State John Kerry and other officials have said they are committed to public transparency, vowing that the State Department will improve its practices under the U.S. Freedom of Information Act. Last year, after an inspector general's audit harshly critical of the agency, Kerry appointed a "transparency coordinator," Janice Jacobs, and said the agency would "fundamentally improve our ability to respond to requests for our records."

But in three separate court hearings last week, officials acknowledged that their records searches were hobbled by errors and new delays and said they need far more time to produce Clinton records. In other cases where the agency has already reached legal agreements with news organizations and political groups, the final delivery of thousands of records will not come until months after the November election — far too late to give voters an opportunity to analyze the performance of Clinton and her aides.

State Department spokesman John Kirby blamed the spiraling delays on mounting requests for more files. "These requests are also frequently more complex, and increasingly seeking larger volumes of documents requiring more time, more resources and frankly, more interagency coordination," Kirby said.

The State Department said in court that it had miscalculated the amount of material it expected to process as part of a public records lawsuit from Citizens United, a conservative interest group. In basic searches of 14,000 pages of records, officials failed to include the "to" and "from" lines of the messages, missing many possible records.

"These delay tactics by the Obama administration look like nothing more than an assist to former Secretary Clinton," said the group's president, David Bossie.

The AP had better luck asking for files about the role Clinton or her aides played in a 2011 decision allowing the British defense contractor BAE Systems plc to avoid being barred from government work and instead pay a $79 million fine. The AP received some records, but last week, the judge said he will likely order the State Department to turn over remaining files in September instead of mid-October, as the agency proposed.

Government lawyers said they need to review thousands of pages and allow the files to be examined by BAE's lawyers in case the company identifies proprietary material that would need to be censored.

"I'm not going to set them for October, two weeks before the election, that's ridiculous," Leon said.

In a third court case, the Gawker.com news site was told by State Department lawyers last week that the agency had failed to provide at least 100 email attachments from Philippe Reines, a Clinton aide who used a private account to send work-related messages. Gawker and the agency agreed that the State Department would turn over the missing material by September.

Also last week, during another legal proceeding involving Huma Abedin, Clinton's closest aide and her former deputy chief of staff, Abedin said she "was never asked to search my emails for anything related to FOIA when I was at State."

Logs of requests showed that Abedin's emails had been sought at the time by reporters for Gawker, Huffington Post and other organizations.

Kirby told the AP that he could not comment on whether Abedin's files were properly searched during Clinton's tenure. But he added that "we have acknowledged that historically we did not have a consistent practice for searching emails in the Office of the Secretary."