A federal court judge ordered the Trump administration to stop winding down census operations until a court hearing later this month over whether the 2020 count should keep going through October.

U.S. District Judge Lucy Koh in the Northern District of California granted a temporary restraining order requested Thursday by plaintiffs who have sued the government over its surprise decision last month to end the count a month earlier than it had planned.

A filing in the case by the government last week revealed that the Census Bureau had already begun ratcheting down the count, prompting the civil rights groups and local jurisdictions that filed the suit to ask for the order.

The order is set to last until a Sept. 17 court hearing over the plaintiffs’ request for counting to continue until Oct. 31, the date the Census Bureau set months ago in response to coronavirus-related delays.

The government had asked Congress for an additional four months to report its data — a delay the House approved in its coronavirus relief bill but the Senate has yet to approve. Census officials said publicly in July that because of the pandemic-related delays, the bureau could no longer deliver a full and accurate count by the constitutionally mandated deadline of Dec. 31.

The modified schedule the bureau had been working with would have meant the data would have been delivered April 30, 2021. But in early August, the government reversed course and said it would keep to the December deadline.

The ruling blocks the government from implementing plans laid out in a leaked Aug. 3 internal document outlining steps the bureau could take to speed up its operations.

In her ruling, Koh said the sole evidence the government submitted in opposition to the request for the restraining order was the Sept. 5 declaration of Albert E. Fontenot Jr., the bureau’s associate director for decennial census programs — a statement that appeared to bolster the arguments of the plaintiffs.

In it, Fontenot said the bureau had already begun terminating some employees, adding, “It is difficult to bring back field staff once we have terminated their employment. Were the Court to enjoin us tomorrow we would be able to keep more staff on board than were the Court to enjoin us on Sept. 29, at which point we will have terminated many more employees.”

Koh said Fontenot’s declaration “underscores Plaintiffs’ claims of irreparable harm.”

Census data is used to determine a decade’s worth of congressional apportionment, federal funding and redistricting. This year’s count has been beset by problems caused by the pandemic, including a delayed timeline and a higher than usual attrition rate among temporary employees hired to complete the count and track down households that don’t self-respond to the survey, including many minorities, immigrants and other ­hard-to-count groups.

“Today’s ruling is a necessary and encouraging first step toward saving the 2020 Census from a massive undercount that will disproportionately affect our country’s communities of color,” said Thomas Wolf, senior counsel and Spitzer Fellow with the Brennan Center’s Democracy Program, which is representing the plaintiffs, which include the National Urban League, the Black Alliance for Just Immigration, the League of Women Voters and jurisdictions in Texas, Washington state and California.

“Today’s ruling buys the census some precious and indispensable time by barring the administration from shutting down the count while the federal courts are still considering our request for relief,” Wolf said.

The Census Bureau did not respond to questions about how much of the winding-down plan it has implemented since the government’s Aug. 3 announcement that it was moving up the end of the count.

In a statement, the bureau said it was “obligated to comply with the Court’s Order” and was “taking immediate steps to do so. . . . Enumeration will continue.”

Plaintiffs in this and other census-related cases have accused the administration of seeking to rush and manipulate the census count to give an advantage to Republicans in representation and funding.

Census experts have warned that rushing the collection and processing of the data will result in an inaccurate count.