The Australian Workers’ Union has successfully challenged the union regulator’s decision to have police raid its offices in Melbourne and Sydney but fell short in its attempt to show the investigation was motivated by an improper purpose.

On Friday the federal court justice Mordecai Bromberg rejected the AWU’s position that raids on their offices in October 2017 by the Registered Organisations Commission (ROC) were made to “embarrass or politically harm” then-opposition leader Bill Shorten.

But the AWU succeeded in showing the “suspicion” that the union had breached its rules was not a reasonable ground to conduct the raid, meaning the case will now move to consider whether the warrants were invalid and evidence collected should be returned to the union.

Although the judge found no wrongdoing by then-employment minister Michaelia Cash, the judgment is politically embarrassing to the government since it concludes Cash’s advisor David De Garis and Michael Tetlow in then-justice minister Michael Keenan’s office tipped media off about the raid.

In October 2017 police raided the AWU headquarters investigating whether donations made to GetUp and Labor candidates in 2005 were authorised under the union’s rules.

On Friday justice Bromberg rejected the AWU’s claim the regulator had no power to investigate alleged historical breaches.

The judge found that the ROC’s delegate Chris Enright believed if the union had made the political donations then those acts were in breach of its rules, the “reasonable grounds” on which he relied to order the raids.

But the judge said there was “no basis” for this opinion, citing a section of industrial law that after four years officers’ conduct must be “taken to have been done in compliance with the rules” of the union.

Justice Bromberg rejected the AWU’s claims the investigation was initiated for an improper purpose, concluding the evidence “does not establish” Enright had taken Cash’s political interests into account.

The judge noted Enright’s evidence that he had assumed Cash had a “political purpose” when she referred the matter to the ROC for investigation and that purpose was to harm Shorten.

But Bromberg said this was Enright’s “own understanding” and he had “no basis” to find Enright had knowledge of Cash’s actual purpose. The judge declined to make any finding on the credibility of Cash denying she intended to harm Shorten.

The judge noted that at times Enright was “overly protective of his own conduct and the conduct of the commission” and described it as “unwise” to have had direct contact with the minister’s office before deciding to conduct an investigation.

But the judge concluded it was more likely Enright “unconsciously” reconstructed events due to the pressure of public attention rather than attempting to protect Cash, accepting his denial of improper purpose.

Maurice Blackburn principal Josh Bornstein, who is acting for the AWU, said the judgement makes clear “the ROC had no proper legal basis to conduct an investigation into the AWU’s compliance with its rules some 10 years earlier”.

Labor and the Australian Council of Trade Unions also seized on the result, warning that the Coalition’s Ensuring Integrity bill would give even more power to the ROC to seek deregistration of unions and disqualification of their officials.

The shadow industrial relations minister Tony Burke argued the public “simply cannot have any faith in [the ROC’s] competence or its impartiality”.

The ACTU secretary Sally McManus said the result showed the raid “wasn’t justified and was used as a political weapon by staff in two ministerial offices”.

In October 2017 Cash repeatedly denied her office’s involvement in leaking the impending raids to the media but then-senior media adviser, David De Garis, resigned after Buzzfeed revealed he had tipped them off. The AFP then set up an investigation into the leak.

In July 2018 the police referred the media tipoff to prosecutors to consider whether there was sufficient evidence to lay charges, but the Commonwealth Director of Public Prosecutions later concluded there were “no reasonable prospects of a conviction” for the unauthorised leak.