Greyhound racing is to be banned in Wales, after Senedd members voted to outlaw the practice.

The move was backed by animal welfare groups, who said that thousands of dogs in the UK have died in recent years due to racing in the "inherently dangerous" sport.

But the legislation faces a legal challenge and accusations ministers did not consult on it properly.

Before the vote it emerged civil servants had told the Welsh government not enough evidence had been gathered to justify a ban. Ministers said they could not comment during "ongoing litigation".

Dogs Trust chief Owen Sharp called it a "landmark moment" for dog welfare.

Senedd members voted to bring in the ban by 39 votes to 10, with two MSs abstaining.

Under the legislation the earliest greyhound racing would be banned is April 2027 and the latest April 2030.

There is only one track in Wales - Valley Greyhounds in Ystrad Mynach, Caerphilly county.

The Scottish Parliament will discuss banning the sport on Wednesday, but currently does not have any tracks after the last one closed last year.

Labour Welsh ministers decided to go ahead with the ban as part of a deal with Welsh Liberal Democrat Jane Dodds to get their budget passed by the Senedd last year.

Speaking in the Senedd she said "by passing this bill, we will be saying as a nation that foreseeable and unavoidable harm to animals cannot be justified in the name of sport or in the service of gambling revenues".

An application for judicial review from the Greyhound Board of Great Britain's (GBGB) was heard in Cardiff last week, with a judgement expected within weeks.

GBGB has accused the Welsh government of failing to carry out a consultation lawfully and hoped to have the ban ruled unlawful.

In advice to Rural Affairs Secretary Huw Irranca-Davies officials warned there was a "high risk" of a court challenge but said the legislation was "clear and proportionate and deliverable".

Officials had recommended developing proposals for the licensing of owners, saying it offered "the best balance of welfare gains" for the dogs.

But Plaid Cymru's Llyr Gruffydd said the legislation had been rushed and "doesn't stop the breeding of greyhounds in Wales for racing. It doesn't stop the training of greyhounds in Wales. For racing, dogs can still be kept in Wales, raced in England".

The ban was welcomed by the Cut the Chase coalition, made up of Blue Cross, Dogs Trust, Greyhound Rescue Wales, Hope Rescue, and RSPCA Cymru.

It said: "For too long, dogs have paid the price for this outdated form of entertainment, with injuries and deaths that are entirely preventable."

Animal welfare charity the League Against Cruel Sports also welcomed the ban and called for it to be implemented speedily.

The league's Jamie Adair said: "The death and injury toll of greyhound racing is quite simply shocking, and goes beyond what people see at the racetracks."

Ken Skates says he would have been put off from going to university if it was as expensive as it is now.

The Senedd will vote on whether to ban the sport but the decision faces a legal challenge.

The BBC Wales programme is being broadcast live at 20:00 GMT and will also be available on iPlayer.

Campaigners say a "lethal" loophole means there are few restrictions on the sale of catapults.

He says the Greens could win around five to 11 seats in May's Senedd election.