The docking of dogs' tails in Scotland will be banned from the end of April, the Scottish Executive has announced.
Dogs in Scotland will no longer have docked tails from May
Those who break the law face six months in prison or a fine of up to £5,000.
Animal Health and Welfare Minister Ross Finnie said the step had not been taken lightly and had followed wide consultation.
The docking of lambs and pigs tails' and ear tagging are among the exemptions in the Animal Health and Welfare (Scotland) Act.
The procedure of micro-chipping pet animals is also exempt along with the castration of farm animals.
The act bans procedures which interfere with the bone structure or sensitive tissue of animals for non medical reasons.
Mr Finnie said: "Tail docking of dogs involves the removal of most or part of the tail, severing muscles, tendons, nerves and sometimes bone or cartilage.
"That cannot be justified because of a possibility that the dog may injure its tail in later life.
"A ban on tail docking is not a step which we have taken lightly."
He said the arguments against docking outweighed those in its favour.
"Tail docking is opposed by the leading veterinary organisations and I'm clear that ending tail docking will improve animal welfare in Scotland," he said.
The Royal College of Veterinary Surgeons (RCVS), the British Veterinary Association (BVA), the British Small Animal Veterinary Association (BSAVA) and the Scottish SPCA all oppose tail docking except where a tail is injured or diseased.
A poll commissioned by Advocates for Animals found more than two thirds of Scots believed the docking of dogs' tails should be banned.
Advocates' political director Libby Anderson said: "We welcome the Scottish Executive's approach, which recognises that animals should not routinely have body parts removed without there being over-riding welfare reasons to do so.
The docking of lambs' tails will be exempt
"We believe that this approach should be extended to all mutilations of animals.
"We need a wholesale review of all procedures that cause pain."
The Scottish Gamekeepers Association had argued that working dogs are prone to injuring their tales in heavy undergrowth, causing them more suffering than docking.
Chairman Alex Hogg said: "The minister has failed in his obligation to protect the welfare of our working dogs and condemned many breeds to a life of pain in his attempts to curry favour with animals rights activists.
"The countryside will not forget."
He added that dog owners were now likely to take bitches to England, Wales or Ireland to give birth, where the puppies can then be docked.
However, he said the act's provisions precluded owners from transporting Scottish-born puppies to England to have the procedure carried out.
Conservative rural affairs spokesman Alex Fergusson criticised the ban.
"It is complete and utter folly which flies in the face of all reasonable evidence," he said.
But the decision was welcomed by the League Against Cruel Sports' Scotland campaigner Louise Robertson.
"This is a really positive step for the Scottish Executive to ban the cruel practice of animal mutilations," she said.
"It is yet another example of Scotland taking the lead over the rest of the UK on important animal welfare issues."