Corporation lawyers argued that a Scottish court was wrong to bar foreign national "A" from being identified after he said he would be at risk of "life threatening" violence when he returned home, but a panel of five Supreme Court justices - unanimously upheld the ban.
The 47-year-old arrived in the UK in 1991 and was later granted indefinite leave to remain after marrying a British woman.
In 1996, A was jailed for four years for indecent assault on a woman and sexual offences against a child and was ordered by the Home Secretary to be deported at the end of his sentence.
The BBC was challenging an anonymity order made by the Court of Session in judicial review proceedings stemming form a tribunal's decision to go ahead with deportation. Lord Reed said: "A is now residing in the country where, as the tribunal concluded, he is at risk of serious violence if his identity becomes known in connection with these proceedings."