Australia has used a so-called "backpacker tax" to illegally tax foreign workers from eight countries, according to a landmark ruling.
In 2017, the government imposed a controversial 15% tax rate on two visa categories for working holiday-makers.
But a court on Wednesday found the levy was in breach of existing treaties with the UK, US, Germany, Finland, Chile, Japan, Norway and Turkey.
Tens of thousands of foreign nationals may be owed money, local media said.
The Australian Tax Office said it was considering whether to appeal against the ruling.
The levy was challenged by an international tax company on behalf of a British tourist, Catherine Addy, who worked in Australia between 2015 and 2017.
She welcomed the ruling, telling ABC News: "I think it is wrong that foreigners should be taxed more harshly than Australians when they are doing the same work."
About 150,000 foreigners travel to Australia every year on working holiday visas, with many finding work in the farming and hospitality industries.
The Federal Court of Australia said the tax could not be applied to citizens of those eight countries who had been employed on category 417 or 462 visas.
This was due to treaties which required Australia to tax those foreign nationals in the same way as local workers.
Unlike foreign workers in Australia, locals do not pay any tax until their yearly income exceeds A$18,200 (£9,700; $12,500). In contrast, foreign workers on 417 or 462 visas are taxed 15% on the first $37,000 they earn.
In his ruling, Justice John Logan described the tax as "a disguised form of discrimination based on nationality".
During her working holiday, Ms Addy lived mainly in a house share in Sydney's Earlwood, a point that proved to be crucial to the case.
This meant she was considered a "resident" for tax purposes in Australia, while other foreign nationals who move around may be considered "non-residents".
The ruling may force the government to repay hundreds of millions of dollars in total, local media reported.
Taxback.com, the accounting firm that organised the lawsuit, said it was clear the "backpacker tax" breached several international agreements when it was introduced in 2016.
"It also damaged Australia's reputation as a working holiday destination," Joanna Murphy, the firm's CEO, said.
The Australian Tax Office sought to play down the ruling, saying it would have no impact for most working holidaymakers.
"This decision only affects the tax rates applying to a minority of working holiday-makers who are also residents, and only those from countries affected by a similar clause in the double tax agreement with their home country," it said.
Colin Mathews, 25, from Cornwall, lived and worked in Australia between October 2018 and May 2019, with his fiancée Emily.
When he returned from Australia, Mr Mathews said he had 15% deducted from wages he earned at a call centre.
"Local Australians couldn't believe we had to pay extra tax," Mr Mathews told the BBC. "I'm not averse to paying tax - I was using Australian services - but it should be on the same terms."
Oliver Bastock, from Derbyshire, is currently living in Melbourne and works in marketing, after moving to Australia in June 2018.
He said the tax system was confusing, adding he had no idea "why you don't get anything back".