(1) An unlawful non - citizen detained under section 189 must be kept in immigration detention until:
(a) he or she is removed from Australia under section 198 or 199; or
(aa) an officer begins to deal with the non - citizen under subsection 198AD(3); or
(b) he or she is deported under section 200; or
(c) he or she is granted a visa.
(2) To avoid doubt, subsection (1) does not prevent the release from immigration detention of a citizen or a lawful non - citizen.
(3) To avoid doubt, subsection (1) prevents the release, even by a court, of an unlawful non - citizen from detention (otherwise than as referred to in paragraph (1)(a), (aa) or (b)) unless the non - citizen has been granted a visa.
(4) Subject to paragraphs (1)(a), (b) and (c), if the person is detained as a result of the cancellation of his or her visa under section 501, 501A, 501B, 501BA or 501F, the detention is to continue unless a court finally determines that the detention is unlawful, or that the person detained is not an unlawful non - citizen.
(4A) Subject to paragraphs (1)(a), (b) and (c), if the person is detained pending his or her deportation under section 200, the detention is to continue unless a court finally determines that the detention is unlawful.
(5) To avoid doubt, subsection (4) or (4A) applies:
(a) whether or not there is a real likelihood of the person detained being removed from Australia under section 198 or 199, or deported under section 200, in the reasonably foreseeable future; and
(b) whether or not a visa decision relating to the person detained is, or may be, unlawful.
(5A) Subsections (4) and (4A) do not affect by implication the continuation of the detention of a person to whom those subsections do not apply.
(6) This section has effect despite any other law.
(7) In this section:
"visa decision" means a decision relating to a visa (including a decision not to grant the visa, to cancel the visa or not to reinstate the visa).