The government detained the men under section 501 of the Migration Act, which allows for detention and deportation if the minister or a delegate judges that a person who is not a citizen fails the “character test”, usually because he or she has committed a criminal offence. When the error was realised the men were released from detention.

Late Tuesday, a spokesman for the immigration department confirmed the unlawful detention, saying “two individuals were detained after their visas were cancelled mandatorily under section 501”.

“After it was identified that each individual held dual Australian citizenship, arrangements were immediately made for their release from immigration detention.

“The circumstances surrounding their detention have been reviewed and appropriate safeguards have been implemented.”

Border Force has been plagued by controversy since its inception as the “operational arm” of the immigration department in 2015.

In August 2015 it faced spontaneous street demonstrations when it announced a Melbourne operation to stop and interrogate the visa status of “any individual we cross paths with”. Victoria Police and Border Force cancelled the operation in the face of a public backlash.

And it emerged on Monday that the ABF commissioner, Roman Quaedvlieg, is on extended leave and facing an external investigation over allegations of impropriety in a “personal matter” involving a subordinate member of staff and an allegedly irregular promotion with the ABF.

The immigration department was at the centre of two scandals over the wrongful detention and illegal deportation of Australian citizens or permanent residents more than a decade ago.

In 2001 the department deported an Australian citizen, Vivian Alvarez Solon, to the Philippines, because it wrongly assumed she had been trafficked into Australia as a sex slave. The department realised she was an Australian citizen in 2003, and knew it had unlawfully deported her, but did not tell her family, who had reported her as a missing person, until 2005.

In 2004 and 2005 an Australian permanent resident, Cornelia Rau, who was suffering an acute mental health episode, was detained for 10 months, including in prison, by the immigration department, because it failed to follow its own procedures for identifying her.

A subsequent inquiry by the former AFP commissioner Mick Palmer found a “serious cultural problem” within the department. Palmer said the department showed weak leadership, with untrained and incompetent staff given “exceptional, even extraordinary powers” and focused on detaining and deporting people without any concern for due process or checks.

The commonwealth ombudsman further investigated 221 cases of Australian citizens being wrongly and illegally detained by immigration officials. One was illegally detained three times for a total of eight months.

Sweeping changes were made to department processes and oversight for deportation and detention orders but department sources have told Guardian Australia these have been steadily eroded or reversed.

Border Force admits it failed in its response to Nauru files abuse claims

Read more

Prof George Newhouse, principal solicitor of the National Justice Project and the lawyer who acted for Rau and Solon, said he had seen lives destroyed by bungling in the department.

“Over a decade ago the Department of Immigration were criticised for acting like a bunch of cowboys because of their failure to implement due process and to make proper investigations – all because they were under pressure to deport people and please their political masters.”

Newhouse said the changes to impose oversight on bureaucratic and ministerial decisions were sensible and had made the process more robust, but these had been rolled back for political purposes.

“It doesn’t surprise me in the slightest if the Turnbull government and Peter Dutton are going back to those bad old days.

“While we don’t know the details of these two new cases,” he said, “whoever they are and whatever they are alleged to have done, they are Australian citizens. To wrongfully detain two citizens on Christmas Island is a worrying sign that the department may be out of control once again.”