In a decision published on Friday, Federal Court Judge Bernard Murphy ruled the girl be brought to Australia for specialist mental health treatment, noting the separation of the girl's parents and years on Nauru without hope of resettlement had taken a toll on the child's mental health.
The December judgment said the commonwealth government and Minister for Immigration and Border Protection had previously declined requests for her transfer.
Judge Murphy granted an urgent injunction to bring the girl to a place with a specialist child mental health facility.
The girl and her family arrived at Christmas Island in 2013 before being placed in Nauru's offshore processing centre and granted temporary settlement visas after being deemed to be refugees.
A report by child psychiatry specialist Louise Newman stated at the December hearing that the girl was at "extreme risk" of suicide, may have been developing a psychotic depressive illness and should be urgently moved to Australia for treatment.
National Justice Project principal solicitor, George Newhouse, whose firm is acting on behalf of the family, asked for privacy.
Readers seeking support and information about suicide prevention can contact Lifeline on 13 11 14.
Multicultural Mental Health Australia www.mmha.org.au.