The man, who has been living in Switzerland since 2008, argued that he would face ill-treatment or worse because homosexuality remains a crime in the West African state.
The authorities, however, based their deportation order on reports that Gambian officials were not applying the anti-homosexuality laws in practice.
They also determined that the man was not at risk of danger from his own family, despite his claims to the contrary.
But the European court said Switzerland should have taken into account that “ill-treatment might also emanate from non-state actors other than family members,” noting anti-gay sentiments stirred up by government officials.
“Persecution relating to sexual orientation and gender identity by State actors might also take the form of individual acts of ‘rogue’ officers,” the court said in a unanimous ruling by seven judges.
As recently as June, Gambia’s government said it had no intention of decriminalising homosexuality, with punishments that can include hefty prison sentences.
The European court said carrying out the deportation without a new assessment of the risks in The Gambia would be a violation of the European Convention on Human Rights.
It ordered Switzerland to pay the man 14,500 euros to cover legal fees.