The Bill, which reached Stage Three approval ahead of the Scottish Parliament going into recess for the election in May, increases the powers of investigation and penalties to tackle the issues such as dog attacks on livestock and dog fouling.
Irresponsible dog owners can now face imprisonment for up to 12 months and/or a fine of up to £40,000.
The Bill also extends the definition of livestock to include modern types of farmed animals - such as alpacas, llamas and buffalo - which were not farmed when the UK Bill was passed in 1953.
NFU Scotland president Martin Kennedy said: “With dog attacks on livestock occurring daily, and irresponsible dog ownership persisting, I thank Emma Harper for her tireless efforts to address this.
“As someone who has seen several dog attacks on my sheep in the past, the pain and suffering is dreadful to see. The cost to livestock owners is often high, both financially and emotionally, and such attacks are easily avoidable.
“It was clear there was a need for legislation, stronger penalties and appropriate compensation to hammer home the responsibility and liability of dog owners who do not exercise their pets responsibly on agricultural land. This Bill is a big step forward.”
Ms Harper, who is also the SNP candidate for Galloway and West Dumfries, has been working on the legislation for four years.
It was the last piece of legislation the current Parliament voted on, gaining cross-party support, and will now go for Royal Assent before becoming law in around six months time.
Ms Harper said: “The Bill provides much greater clarity to Scotland’s legal bodies, police and courts and it tidies up the legislation surrounding attacks on livestock as, at the moment, different legislation can be used and it is often confusing and difficult to understand.
“I want to thank all stakeholders for their continued support throughout the process of taking this Bill forward and I look forward to continuing a positive relationship with all of them as we move into the future.”