The head of Australia's Immigration Department has resigned after a scathing report on cases of wrongful detention and deportation.
Illegal arrivals are detained while their cases are heard
Prime Minister John Howard said he had accepted the resignation of secretary Bill Farmer, who would become the country's next ambassador to Indonesia.
He said he had appointed former immigration official Andrew Metcalfe as his replacement.
Australia has one of the strictest policies on immigration in the world.
The investigation into 201 cases of possible wrongful detention and deportation was carried out by former police commissioner Mick Palmer.
It highlighted mistakes which included the wrongful detention and deportation of two mentally-ill women.
"There have been mistakes made, and I'll have more to say about this, and plainly people who are Australian citizens should never be treated as if they weren't," Mr Howard said.
The prime minister had resisted calls to replace Mr Farmer, but scathing excerpts from Mr Palmer's report, which has been handed to the government and is due to be released next week, highlighted a catalogue of failings.
They included the wrongful detention of mentally ill German-born Australian woman Cornelia Rau, which Mr Palmer said had exacerbated her illness.
Lawyers for mentally ill Australian woman Vivian Alvarez have said that she had a partially severed spinal cord and had to sign her deportation papers with a thumbprint when she was wrongly sent back to the Philippines four years ago.
Australian citizen Vivian Alvarez was mistakenly deported
Mr Farmer has apologised for failings by his department in some of the cases investigated by Mr Palmer.
Australia's strict policy on illegal immigration includes detaining illegal arrivals, illegal workers and people who overstay visas while their cases are heard.
The policy has been criticised by human rights groups.
Last month, Mr Howard softened detention laws to allow children and families to be freed from custody while refugee claims were heard.