An Indian doctor briefly charged over failed bomb attacks in the UK in June has won a court battle to return to Australia on a work visa.
Dr Haneef is currently in Saudi Arabia on pilgrimage to Mecca
The Federal Court of Australia dismissed an appeal by government lawyers against a judge's decision to restore Mohamed Haneef's visa.
Ex-Immigration Minister Kevin Andrews revoked the former Gold Coast Hospital registrar's visa on character grounds.
Dr Haneef was accused of links with failed attacks in London and Glasgow.
The decision by the former immigration minister to cancel the Indian doctor's visa was quashed by a federal court judge in August.
Second government defeat
Government lawyers then appealed the decision to the full bench of the court but lost the case on Friday morning.
HANEEF CASE TIMELINE
2 July: Arrested in Brisbane
14 July: Charged with providing "reckless support" to terrorism
16 July: Granted bail, but kept in custody after work visa revoked
27 July: Charges dropped
29 July: Returns to India
21 Aug: Court overturns government visa decision
The BBC's Phil Mercer in Sydney says it is still not clear if Dr Haneef will be able to reclaim his work permit as the government still has the option of appealing to the High Court of Australia.
Dr Haneef was arrested on 2 July at Brisbane International Airport and held for several days before being charged with giving "reckless support" to terrorism.
But the case against the 27-year-old father-of-one collapsed and he flew out of Australia back to India on 29 July. He has consistently denied any wrongdoing.
The Australian government cancelled Dr Haneef's work visa after a magistrate granted him bail, then refused to reinstate it when charges against him were dropped.
He is currently visiting Saudi Arabia for the annual Muslim Hajj pilgrimage to Mecca.
Dr Haneef is the cousin of Sabeel Ahmed, one of three people charged in the UK over the failed attacks.
Mr Ahmed's brother, Kafeel, was the driver of a jeep which crashed into Glasgow Airport in flames on 30 June. He died from his injuries in August.