BUCHAREST, Romania—A bill allowing stray dogs to be euthanized is legal, Romania's constitutional court ruled Wednesday, prompting hundreds of dog lovers to block a main road outside Parliament in protest.

The ruling came weeks after a 4-year-old boy's fatal mauling in Bucharest led the government to draft the legislation.

Protesters, who blew whistles and brought some of their dogs, yelled "Criminal court!" and "May you have the same fate as the dogs!"

The bill needs to be signed by the president before it can become law. Under it, stray dogs will be taken to shelters and—if not adopted or claimed within 14 days—they will be killed. The Vier Pfoten animal welfare group criticized the ruling, saying it ignored an appeal by the European Commission to Romania to protect animal rights. The group urged Romanian mayors and vets to stop the "mass killings" of dogs.

The World Society for the Protection of Animals criticized the ruling and called the bill "both inhumane and ineffective" and called on the court and the government to find a more "effective, sustainable and humane solution to manage the stray dog population."

Bucharest City Hall says the capital has 64,000 stray dogs, while animal rights groups say there are 40,000. A hospital that handles infectious diseases has treated 9,760 people for dog bites in the first eight months of this year.