MPs have voted to ban the docking of dogs' tails - but with an exemption for working dogs, such as those used by the police, Army or rescue services.
Boxers are among breeds which have had their tails docked
At the moment nearly 80,000 puppies in the UK have their tails removed each year - many for cosmetic reasons.
Critics say the practice is cruel, but supporters claim it is necessary for certain breeds to avoid injury.
The ban, with the exemption, passed by 476 votes to 63 during the report stage of the Animals Welfare Bill.
The government had been in favour of retaining the status quo, that docking should continue as long as it was carried out by a qualified vet.
But ministers agreed to let MPs settle the issue by putting forward three options for them to vote on - an outright ban, a ban with exemption for working dogs, or the status quo.
An outright ban on tail docking of dogs in England and Wales was rejected by just 11 votes.
The exemptions backed include dogs used by police forces, rescue services, the military, pest control firms and in sport shooting.
Animal Welfare Minister Ben Bradshaw said docking would continue when it was recommended by a vet for medical reasons.
Even with the exemption about 80% of current dockings would be illegal under the ban.
He said he favoured a ban with an exemption for working dogs after it was shown by the police that 20 dogs had had to have their tails docked in the last two years after being injured during security operations.
Supporters of docking argued the practice was necessary for certain breeds, such as boxers, to protect them against tail damage and for hygiene reasons.
Tory spokesman Bill Wiggin, who opposes a ban, said while docking "probably can hurt", it usually did not.
"I think that this is something that people who own dogs have to deal with themselves. I don't like bans, I don't think there is a need to ban," he said.
Tory Henry Bellingham asked whether the "voice of the countryside" had "really been heard", adding that there was no "lasting pain" when a tail was docked.
But Labour's Shona McIsaac called for a total ban, describing the practice as "mutilation".
Liberal Democrat Norman Baker also backed a complete ban, saying: "A dog is born with a tail and therefore presumably it has a purpose otherwise it would have been eliminated through genetic manipulation over many generations."
The British Veterinary Association says 90% of vets are against what it describes as a painful procedure which should only be carried out for medical reasons.
David Bowles, RSPCA head of external affairs, said he would have preferred a total ban.
"MPs have rightly signalled that it is unacceptable in a civilised society to amputate a puppy's tail purely because some people think that it is aesthetically pleasing to disable a dog in this way," he said.
Mike Hobday, of the League Against Cruel Sports, said: "This is a scandalous and shabby compromise that will lead to unnecessary suffering for large numbers of dogs in the shooting industry."
The Animal Welfare Bill, which is currently going through Parliament, will impose fines of up to £20,000 and prison sentences of up to 51 weeks for animal cruelty.
It will also allow RSPCA inspectors to intervene earlier when an animal is reported as suffering, and give people clear instructions on how to look after their pets.