You were crossing a yard while searching for your pet. The owner of the home came out and told you to get off the land. You refused, because you needed to get your dog back home safely. Now, you are at home and facing an officer who says you've been reported for trespassing.
Did you really trespass in this situation, and should you be held liable?
There are many times when trespassing is legally necessary. Most people wouldn't say much about a situation like yours as long as you were being reasonable. For instance, if you have always crossed the yard to get to school with permission, that might allow you to use easement as a defense. In the past, you had permission from your neighbor to cross, so your attorney could use that to help support your case.
Another thing you can do is argue that you entered the property to prevent a nuisance. For instance, if your pet ran into the neighbor's garden, trespassing would be legal in most cases because you were trying to collect your pet before it caused damage to the property or caused a nuisance. If your pet did cause damage, you would still be liable for the cost of those damages, although you may not end up facing criminal charges for trespassing depending on your situation.
There is no specific rule that would allow you to trespass on another person's property specifically due to your pet's escape, but your attorney may choose these or other legally allowed situations to defend you and protect your rights.
Source: US Legal, "Defenses," accessed June 20, 2017