The man, who is in his early 30s, had been given a 27-month jail term after being convicted of conspiring to supply cannabis seven years ago.
Ministers said he should be automatically deported. But the man said that would be 'unduly harsh' on his British family.
He said his stepdaughter had been experiencing significant mental health difficulties and was in the process of seeking gender reassignment
She needed a high level of support from her family and was 'particularly close' to him, the man claimed.
An immigration tribunal ruled in his favour last in 2019, and a judge has now dismissed a Home Office appeal.
The tribunal ruled that the man's 'continuing support' was 'essential' to his stepdaughter's 'emotional and psychological well-being' and that the 'impact of his deportation' would be 'unduly harsh' on her.