The government has been defeated in the House of Lords as peers voted to ban sex in public toilets.
Tories say current laws are not specific enough
The vote came on a Conservative amendment saying anybody caught involving in "cottaging" should face prosecution and face jail terms of up to two years.
The Tories tried to outlaw the activity after ministers dropped proposals for a new law that banned couples having sex in public places.
But the Home Office on Friday said the change would make the bill unworkable.
Ministers will try to overturn the amendment when the bill returns to the Commons.
The government originally removed the proposed offence of "sexual activity in a public place" from the Sexual Offences Bill after concerns raised by the Police Federation.
Police had feared the plan would make it harder to prosecute incidents of sex in public toilets in cases where cubicle doors were closed.
One of the most famous "cottaging" offenders was British pop star George Michael, who was fined for committing a "lewd act" in a Los Angeles public lavatory in April 1998.
Ministers conceded the measure was also impractical because it would also have outlawed sex in a private garden which was visible from a public place.
Sex in public lavatories should be completely outlawed because of the effect on other people
Instead Home Office Minister Hilary Benn said the government would rely on the existing common law offence of "outraging public decency".
But the Conservatives argue that for public decency to be outraged, the activity will need to have been committed in public and capable of being seen by two or more members of the public.
They say this does not cover being able to hear a sex act going on in the next cubicle.
They also point out there are relatively few successful prosecutions - out of 173 cases of sex in public toilets in 2001, only 34 prosecutions were successful (20%).
The bill, which will make sexual "grooming" of children a new offence and generally strengthens protection for the public against sex offenders, was debated at its report stage on Monday.
Before the debate, Baroness Noakes, Tory spokeswoman on the bill, told BBC News Online: "Sex in public lavatories should be completely outlawed because of the effect on other people.
Some toilets are 'no go areas', says Lady Noakes
"It creates places that ordinary people don't want to go and certainly don't want their children to use.
"There are examples where public lavatories have become no go areas.
"We should not have to rely on the old concept of common law and satisfy the terms of outraging public decency, which requires the activity to be capable of being seen."
Lady Noakes said the Tory amendment would be "gender neutral", applying to both homosexual and heterosexual activity as well as sexual activity carried out by an individual.
The penalty for successful conviction would be up to six months jail or a fine in the magistrates' court, or up to two years jail at Crown court.
"This is just about making the law clear," said Lady Noakes, who said the bill was in many respects an "excellent bill".
In Monday's debate, Independent Socialist peer Lord Fitt said any father taking his son into a public lavatory would be
"absolutely disgusted" at what was going on in closed cubicles.
"There will be an outbreak of homophobia and there will be some fathers who
feel as I would have if I were 20 years younger that they could see themselves
taking physical action."
After the defeat, a Home Office spokeswoman said: "We believe that this amendment makes the law
more unworkable and we will look to remedy this in the Commons.
"We all agree that people should be protected from being unwilling witnesses
to overtly sexual behaviour that most people consider should take place in