The federal government is fighting for the right to destroy documents when it loses office, after a judge warned the practice of shredding paperwork to keep it from incoming opponents is possibly criminal and must stop.

The attorney general, Mark Dreyfus, is appealing against a federal court ruling in a freedom of information case that a minister must preserve a predecessor’s documents if an FOI access application remains unresolved when the minister leaves office. It found this applies whether the job changes hands through an internal ministerial reshuffle or an election.

In a court challenge brought by former independent senator Rex Patrick after the Albanese government refused an FOI request for Morrison government documents, Justice Natalie Charlesworth ruled that ministerial paperwork belonged to the office of the minister, not the individual occupant.

This means ministers retain legal responsibility for predecessors’ documents and must preserve them until any FOI process is concluded.

The case highlighted the longstanding practice of ministers shredding some potentially sensitive documents as they left office in the belief that they were not required to hand them on to successors. On that, Charlesworth issued a sharp warning.

“The attorney general may consider it appropriate to bring the judgment to the attention of the whole of government as it does have some ramifications for the handling of FOI requests that are different from the usual administrative and conventional arrangements,” Charlesworth said as she presented her judgment in March.

Patrick had sought access to advice held by the then attorney general, Christian Porter, on the administration of the Morrison government’s controversial $100m sports grants program in 2020.

When refused, he applied to the information commissioner for a review. That process took so long that, by the time it was completed, the portfolio had transferred to Michaelia Cash, then briefly to Katy Gallagher upon the change of government, then to Dreyfus. The commissioner upheld the refusal on the basis that the documents were not in the possession of the current attorney general.

Patrick eventually went to the federal court.

There, he challenged the convention that new ministers were not responsible for former ministers’ documents. He argued that the ownership stayed with the position of attorney general and the commissioner was obliged to consider his application. Charlesworth agreed.

Patrick also noted that governments routinely shredded documents upon leaving office and raised concern that what he was seeking might meet the same fate.

The Australian government solicitor assured the court the documents still existed. But Charlesworth expressed alarm at the practice generally, which she suggested could be unlawful.

“Destruction of a document that is a ‘commonwealth record’ may in some circumstances constitute a criminal offence under the Archives Act,” Charlesworth’s judgment says.

The judge drew a distinction between the law and both convention and politics.

“I accept that there may be very strong political resistance to an outgoing minister transferring documents forming the subject of a pending FOI request to a new incumbent, particularly on a change of government,” Charlesworth said in the judgment. “This court was told that it was common practice for documents not to be transferred … If there be a common practice of the kind suggested to this court in submissions, it is not one that is authorised or contemplated by the FOI Act and it should stop.”

She said it was up to parliament to balance the need for secrecy with the need for public access.

Services Australia paid Bill Shorten’s speechwriter $300,000 a year, Senate estimates told – video

“It is legislation, not political or administrative convention, that is determinative of Mr Patrick’s rights in the present case,” Charlesworth’s judgment said.

Dreyfus’ appeal was this week set for 16 August.

Sydney University law professor emerita Anne Twomey says Charlesworth’s judgment is important for ensuring access to documents after ministers change.

“It will also improve the records available to future historians and to the public if inconvenient ones cannot simply be taken away by ministers when they leave office, or fed through the shredder as seems to be what so often happens,” Twomey said in an analysis of the case on her Constitutional Clarion YouTube channel.

Patrick, who now runs a business offering advice about FOI and lodging applications on behalf of clients as well as his own, told Guardian Australia that Charlesworth’s decision was “comprehensive” and “consistent with principles of ministerial accountability to the public”.

“What’s been filed in the full court by the attorney general is a very high-level legal objection to the judgement,” he said. “We’ll just have to wait to read his detailed arguments to fully understand his concerns.”

Dreyfus’ spokesperson did not respond to a request for comment.