Denmark has become one of the last European countries to ban bestiality.
Until the new law was passed on Tuesday, sex with animals was still legal in the country as long as the animal was unharmed.
Activists claimed the strange law was difficult to prove, and was making Denmark a hotspot for animal sex tourists.
Hungary, Finland and Romania are now the only EU countries where bestiality, or zoophilia, is legal.
Farming Minister Dan Jorgensen introduced the bill in October, arguing the previous laws didn't offer animals enough protection.
At the time, he told the Danish Parliament: "An animal by its very nature cannot say no.
"An animal by its very nature also has a hard time proving that the animal has been hurt by a sexual act.
"Therefore, we need new legislation that ensures that the consideration of the animal comes first."
People convicted of bestiality now face up to one year in prison for a first offence, and two years for repeat offenders.
Parliamentarians who voted in favour of the bill said they did not want Denmark to be the last northern European country where bestiality was permitted, as the country was attracting animal sex tourists.
"There are frequent reports of the occurrence of organised animal sex shows, clubs and animal brothels in Denmark," the Danish Ethical Council for Animals said in a report, though the group admitted it didn't have direct evidence itself.
Only one party, Liberal Alliance, voted against the ban, saying it was at best a waste of time and at worst the state imposing a moral code.
A 2011 report by the Danish Justice Ministry found 17% of vets suspected an animal they treated had been involved in sex with a human.