Labour lost the Lords vote by 186 votes to 133
Labour has been defeated in the Lords over the issue of free speech and laws against inciting homophobic hatred.
Ministers sought to remove a clause which permitted free speech to be used as a legitimate defence in such cases.
But an amendment preserving the clause, tabled by Tory peer Lord Waddington among others, was agreed by 53 votes.
The issue was not about legal protection, he said, but whether any "criticism of sexual practice" should be regarded as inciting hatred.
Ministers sought to overturn a provision in last year's Criminal Justice and Immigration Bill over the law on incitement to hatred on the grounds of sexual orientation and defences against prosecution under the legislation.
The government had been under pressure to pass the bill at the time for broader political reasons but indicated that it would revisit the matter at a later date.
But on Thursday, its attempts to overturn the provision during passage of the Coroners and Justice Bill failed.
The provision at issue provides protection for "discussion or criticism of sexual conduct or practice" when it can be proved it is not intended to stir up or incite hatred.
Lord Waddington, the former Conservative home secretary who tabled the amendment, said the issue was not about the need for legal protection against homophobia.
"The issue is whether there should be a provision to protect free speech similar to that in the offence of stirring up religious hatred," he told peers.
"One must look at the circumstances and the manner in which the words are spoken to see whether they were in fact threatening and driven by hate."
The Ministry of Justice said the defeat was "disappointing" and that it would seek to overturn it when the bill returned to the Commons later this year.
A spokesman said the threshold for prosecution under the law would be a "high one".
"The offence only covers words or behaviour that is threatening and intended to stir hatred.
"The freedom of expression section only serves to make the offence less clear and could be used by those attempting to justify stirring up hatred by a free speech argument."