Pet shops and dealers in England will be banned from selling puppies and kittens under government plans.
The proposals, which have gone out to consultation, will mean those wanting to buy or adopt a pet less than six months old will have to go to the breeder or a rescue centre.
A ban on licensed sellers dealing in dogs and cats less than eight weeks old is already coming in on 1 October.
Campaigners welcomed the announcement, but warned of "potential loopholes".
The ban aims to reduce the health problems associated which emerge when animals are reared in poor conditions.
It is a victory for the Lucy's Law campaign, which has been calling for the ban to be implemented.
The campaign was named after a Cavalier King Charles Spaniel who was badly treated in the puppy farming system.
Lucy was rescued in 2013 at five years old from a Welsh puppy farm. She had a series of health problems, including a curved spine as a result of being kept in a cramped cage, and epilepsy. She died in 2016.
Allow Facebook content?
A petition supporting Lucy's Law was signed by nearly 150,000 people and was debated in Parliament in May.
There are no records of the number of puppies sold via third parties, but the animal charity Blue Cross has estimated it is between 40,000 and 80,000 per year in Great Britain.
The Department for Environment, Food and rural Affairs said fewer than 100 third party sellers - which includes some pet shops - are licensed in England.
Speaking in support of a change, Environment Secretary Michael Gove said: "People who have a complete disregard for pet welfare will no longer be able to profit from this miserable trade."
TV vet Marc Abraham, who launched the campaign for Lucy's Law, told BBC Radio 5 Live that Lucy's Law will make all breeders and puppy farms "completely transparent and accountable" which "completely raises the stakes for animal welfare".
"There's nowhere to hide, a pet shop can't blame the breeder and the breeder can't blame the pet shop," he said.
"Everyone selling is accountable so this is a very exciting time for animal welfare."
He said Lucy was a "beautiful little soul" whose condition when she was rescued was "so heartbreaking".
"Lisa Garner, her owner, rehabilitated her and popped her in the hands of various celebrities and got this huge social media following and helped raised awareness about not only puppy farming, but rescue dog adoption," he said.
"Then she sadly passed away and succumbed to all her injuries in December 2016.
"We launched Lucy's Law a year after her passing as a tribute to her and all the breeding dogs that are hidden from the public."
The Mayhew Animal Home charity has previously highlighted the case of Luna, a Jack Russell terrier who was sold online despite being ill with a suspected skin disease.
At six weeks old, Luna was already under the legal age required for puppies to be sold - but the seller claimed the young dog was 10 weeks old.
In another case, the Dogs Trust said a French bulldog called Lola was forced to travel from eastern Europe so her puppies could be born and sold in the UK at a higher price. Two of her puppies later died.
Paula Boyden, from the Dogs Trust, welcomed the ban but warned "potential loopholes" needed to be closed off for it to be successful. She said there should be additional measures including regulating re-homing organisations.
Caroline Kisko, Kennel Club secretary, said the ban would "stop the suffering of many dogs and send a very strong message to puppy buyers that it is never OK to see a puppy in any environment other than the one it was born and raised in, and with its mum".
Chris Wainwright, deputy chief executive of the RSPCA, told BBC News that a ban was "overdue" and said he hoped it would raise welfare standards.
"We've had this explosion in this market with loads of rogue traders, lots of rogue dealers and it's meant the public are often unsuspecting. They think they're buying from a reputable breeder, actually they're buying from a middle person," he said.
"It means the breeders aren't getting the scrutiny on their premises because they're passing these dogs off to third parties and it often leaves families with sick animals and the tragedy of that occurs."
Queen guitarist Brian May, who supports the Lucy's Law campaign, said it was "a day for celebration".
The Pet Industry Federation said puppy farms should be closed down but added there were concerns that an outright ban on third party sales would lead to sales "going underground".
Other rules already coming into force on 1 October include a requirement for any licensed pet seller to include their licence number in the advert as well as identifying the local authority that issued it and for breeders to show puppies alongside their mother before a sale is made.
In Wales, campaigners have also called for Lucy's Law and the government has said it would "investigate the potential banning of third party sales". Legislation it introduced in 2014 requires all dog breeders to apply for a licence.
In Scotland, a members' bill to end puppy farming was introduced in May.