Internal emails show the government was told the robodebt scheme was unlawful right before the system was suspended in November last year.
In an email to Australian Taxation Office Commissioner Chris Jordan, General Counsel for the tax office Jonathan Todd said the Department of Human Services had received legal advice saying the debts weren't lawful.
"They have advised you that they have received legal advice that debts based solely upon DSS own income averaging of ATO annual tax data are not lawful debts ('Robodebts')," Mr Todd wrote on November 19.
The emails have been released as part of a Senate inquiry into the debt scheme.
In one email Mr Todd wrote that the debts raised by matching tax office data to Centrelink data "are not debts owed to the Commonwealth".
"Therefore you are not in a position to garnish Robodebts when served a notice under s 1233 of the Social Security Act, as the notice would not be in respect of a valid legal debt," Mr Todd told Mr Jordan.
It's not clear when the legal advice was received, but the emails published on Thursday are from November and December last year.
The email shows the tax office didn't know how many debts it garnisheed for the Department of Social Services were based on robodebts, and that if the debts couldn't be identified, pausing all social services debt recovery through the tax office could need to be considered.
Government Services Minister Stuart Robert had claimed a public interest immunity claim over legal advice on the scheme, citing the class action filed in the Federal Court in November.
Mr Robert refused to detail when legal advice was given.
"Whilst I acknowledge that it may often be appropriate for an official to disclose who provided legal advice and when it was provided, having regard to the class action proceedings before the Federal Court and the specific matters of claim in that matter, including a claim of negligence, I consider there are compelling reasons to also keep that information confidential as the disclosure of this information may materially affect the Commonwealth's position," Mr Robert wrote to the committee.
Greens Senator Rachel Siewert, who is chairing the Senate inquiry into the scheme, called for the government to reveal who knew what and when.
"How long did Mr Morrison and the minister know that this scheme was illegal?
"This is a fundamental question and with the government making a claim of Public Interest Immunity over the release of legal advice it is clear that they don't want Australia to know," Senator Siewert said.
Labor's spokesman on government services Bill Shorten called the emails a "smoking gun".
"[Stuart Robert] has consistently refused to level with the public - that even the government know their pet scheme is illegal," he said.
"But emails made public today reveal the truth - the Government put the emergency brakes on its pet scheme because it knows it is unlawful."
Mr Shorten also called for Mr Robert to release details of the legal advice given to the government about the program.
"Since the government maintains it has done nothing wrong then it should have nothing to fear from openly revealing what it knew about Robodebt's legality and when."
Labor opened Question Time by asking about the emails and whether the government regretted starting the illegal scheme, but Mr Robert didn't address the legality of the program and would only say it had been refined.
"As the House would know, on the morning of the 19th of November last year, the government announced a further refinement of the income compliance program," he said.
"This is part of an ongoing commitment to continually strengthen and improve the scheme."
Robodebt refers to a system started by the Department of Human Services in 2016, where annual income data reported to the tax office was matched to historical fortnightly earnings reported to Centrelink by welfare recipients. Where a discrepancy was identified, people were issued with debt notices based on averaging their earnings across 26 fortnights.
The highly controversial system has left more than 600,000 Australians with debts to the government, with little power to challenge the debts.
Last year Gordon Legal announced a class action against the debt scheme, and almost 10,000 people have registered their interest to join the action.
Victoria Legal Aid has also challenged the scheme through the courts, with the government losing a test case last year when the court found the income averaging process was unlawful. That decision was handed down less than two weeks after the emails between the tax officials.
The government is in the process of reviewing the debts raised under the scheme, which is expected to take months.