Nearly 7 percent of ballots in U.S. Postal Service sorting facilities on Tuesday were not processed on time for submission to election officials, according to data the agency filed Wednesday in federal court, potentially leaving tens of thousands of ballots caught in the mail system during an especially tight presidential race.

The Postal Service reported the timely processing — which includes most mail-handling steps outside of pickup and delivery — of 93.3 percent of ballots on Election Day, its best processing score in several days, but still well below the 97-percent target that postal and voting experts say the agency should hit.

The Postal Service processed 115,630 ballots on Tuesday, a volume much lower than in recent days after weeks of warnings about chronic mail delays. Of that number, close to 8,000 ballots were not processed on time, a small proportion but one that could factor heavily in states such as Michigan and Wisconsin, which do not accept ballots after Election Day and could be decided by a few thousand votes.

Earlier Tuesday, U.S. District Judge Emmet G. Sullivan of the District of Columbia had ordered the Postal Service to sweep 12 postal processing facilities that cover 15 states for ballots. But the agency rebuffed that order and said it would stick to its own inspection schedule, which voting rights advocates worried was too late in the day for found ballots to make it to vote counters.

The directive came after the Postal Service disclosed that more than 300,000 ballots nationwide could not be traced. Those ballots received entry bar code scans at processing facilities, but not exit scans. The agency said the likelihood of that many ballots being misplaced was very low; mail clerks had been ordered to sort ballots by hand in many locations, and items that were pulled out for expedited delivery were not given an exit scan.

“We know yesterday that if the sweeps were doing their job, mail that was identified as ballots and were in the system should have been pulled out and delivered, and it may be that affects what we see as the scores,” said Allison Zieve, an attorney representing the NAACP, which brought the lawsuit against the Postal Service with other civil and voting rights groups. “The problem is, in part because of the timing and in part because they haven’t given us all the information we asked for, it’s hard to know whether the numbers we saw today — the low scores for example in Atlanta and Central Pennsylvania — it’s hard to assess how big a problem that is.”

About 101 million Americans cast their ballots before election day, according to an early vote tally maintained by Michael McDonald at the University of Florida, with roughly 60 million others voting in-person on election day. Given the widely publicized issues with mail delivery, experts last week began advising absentee voters to drop off their ballots in-person rather than send them by mail. The high rates of early voting led to generally uncrowded conditions at polling places around the country on election day, although long lines were reported in some areas.

Sullivan had given the mail agency until 3:30 p.m. Tuesday to conduct the “all clear” checks to ensure that any found ballots could be delivered before polls closed. But in a filing sent to the court just before 5 p.m., Justice Department attorneys representing the Postal Service said the agency would not abide by the order, to better accommodate inspectors’ schedules.

Attorney John Robinson, writing for the Justice Department, noted that the daily review was already scheduled to occur from 4 to 8 p.m. on election night. “Given the time constraints set by this Court’s order, and the fact that Postal Inspectors operate on a nationwide basis, Defendants were unable to accelerate the daily review process to run from 12:30 pm to 3:00 pm without significantly disrupting preexisting activities on the day of the Election, something which Defendants did not understand the Court to invite or require.”

“This is super frustrating,” Zieve said Tuesday. “If they get all the sweeps done today in time, it doesn’t matter if they flouted the judge’s order. They say here they will get the sweeps done between 4 p.m. and 8 p.m., but 8 p.m. is too late, and in some states 5 p.m. is too late.”

Sullivan was incensed during Wednesday’s hearing over the sweeps, accusing the Postal Service of attempting to run the clock out on his order to avoid conducting the sweeps.

“It just leaves a bad taste in everyone’s mouth for the clock to run out — game’s over — and then to find out there was no compliance with a very important court order,” he said.

He said that at some point, he would order Postmaster General Louis DeJoy to appear before the court or sit through a sworn deposition, and intimated that he’d consider contempt charges against postal leadership, saying “someone might have to pay a price,” for defying his order.

It was DeJoy’s aggressive cost-cutting regimen, according to postal experts, that created sustained slowdowns in the mail service that over one five-week span delayed more than 7 percent of the nation’s first-class mail.

The Postal Service began election mail “all clear” sweeps in January, agency spokesman David Partenheimer wrote in an emailed statement, to search for misplaced political mail (such as campaign ads) and election mail (ballots, ballot applications and voter registration information).

Since Thursday, he said, agents from the U.S. Postal Inspection Service, the agency’s law enforcement arm, conducted daily reviews at 220 ballot processing facilities. Inspectors walk the facility and observe mail conditions and check daily political- and election-mail logs.

In the past 14 months, Partenheimer said, the Postal Service has processed more than 4.5 billion pieces of political and election mail, up 114 percent from the 2016 general-election cycle.

“Ballots will continue to be accepted and processed as they are presented to us and we will deliver them to their intended destination,” he said.

Timely ballot processing scores, which indicate the proportion of ballots sorted, postmarked and transported within the agency’s one-to-three-day service window, worsened in the run-up to Election Day, according to data the agency submitted to the court. In 28 states, election officials must receive ballots by the end of Election Day to be counted.

Voting and postal experts say the mail agency should be able to process 97 percent of incoming ballots — or completed ballots sent to election officials. But data shows the Postal Service missed that mark seven out of eight days. And in the five days ending Monday, processing scores dropped, from 97.1 percent to 89.6 percent on Monday. . (The Postal Service did not report Sunday data.)

In 17 postal districts that cover 151 electoral votes, Monday’s on-time processing rate was even lower: 81.1 percent.

Sullivan on Tuesday ordered officials from the Postal Inspection Service, the agency’s law enforcement arm, or the Postal Service Office of Inspector General, its independent watchdog, to inspect all processing facilities in the districts of Central Pennsylvania, Philadelphia Metro, Detroit, Colorado/Wyoming, Atlanta, Houston, Alabama, Northern New England (Vermont, New Hampshire and Maine), Greater South Carolina, South Florida, Lakeland (Wisconsin) and Arizona (which includes New Mexico) by 3 p.m.

The Postal Service continued Tuesday to try to track down the more than 300,000 ballots it said had entered processing plants but could not be traced. In 17 postal districts in swing states that account for 151 electoral votes, more than 81,000 ballots were untraceable. In Los Angeles, 48,120 ballots were missing, the most of any district. San Diego was next, with 42,543 unaccounted.

“At this point,” said Zieve, “we don’t have any way of knowing if those ballots are of concern or if they aren’t.”

Sullivan has been more aggressive than judges in Pennsylvania, New York and Washington state to grant increased oversight of the mail system. He has ordered the Postal Service to report daily data on ballot performance scores and to provide written explanations each day for underperforming districts.

He has scheduled daily hearings — some of which have included sworn testimony from postal executives — on the agency’s struggles. On Monday, he lamented the nation’s crazy-quilt of mail-in-voting rules, saying the system should be overhauled.

“When I read about the astronaut voting seamlessly from outer space, there must be a better way for Congress to address all these issues,” he said.

Sullivan contrasted the chaotic mishmash of Election Day rules with the relative simplicity of the federal income-tax deadline: “Think about it. Every year everyone knows to file taxes by April 15th. It’s seamless. If you don’t file, there’s penalties. But everyone knows — that’s a given.”

By contrast, state vote-by-mail deadlines present a spaghetti-like tangle for the Postal Service and voters to navigate.

“Postmarks matter, postmarks don’t matter. … Delivery matters, delivery after a date doesn’t matter. Why can’t there be one set of rules?” Sullivan said, concluding, “Someone needs to be tinkering with the system to make sure it works seamlessly and better for the American voters.”

Spencer Hsu contributed to this report.