BUCHAREST, Romania — Thousands of angry shepherds engaged in a tense standoff with riot police outside Romania’s parliament building Tuesday in protest at a law that restricts the number of sheepdogs they can use and bans them from grazing sheep during the winter.

Authorities say the Carpathian shepherd dogs are aggressive and kill other wild animals, while the grazing ban helps the environment. But shepherds insist the law is an attack on centuries of sheep-rearing in the rural Balkan nation.

Riot police fired tear gas at the shepherds, some of whom were dressed in floor-length sheepskins and were blowing horns, to keep them from charging at the Parliament building. There was a tense standoff lasting until nightfall between hundreds of riot police and the 4,000 shepherds.

Lawmaker Liviu Harbuz later said a parliamentary committee had signed an agreement that will allow the government to adopt an emergency ordinance scrapping the regulation of sheepdogs and grazing.