The gemara says that everyone agrees that when a shomer return something which became assur b'hana'ah, such as chometz that sat in the shomer's possession over pesach, he can say to the ba'alim "here is your item" - הרי שלך לפניך. The shomer would not be responsible for the loss. However, an ox that killed while it was being watched by the shomer, there is a machlokes. Rabbonon hold that the shomer is liable since he allowed beis din to get their hands on the ox, and without them getting the ox, it could not be judged to be killed. R' Yakov argues and says that since they could have judged the ox to be killed without getting their hands on it, the shomer can say הרי שלך לפניך and is not responsible.
Rashi understands that returning issur hana'ah qualifies as returning. Also, all agree that the shomer is not responsible for not hiding the ox from beis din, just as he is not liable for being passive and allowing the chometz to become assur over pesach. The issue here is whether the shomer was negligent by doing an act of handing over the ox to beis din. Rabbonon hold that regarding his "shomer" responsibilities he is not liable because for that he can claim הרי שלך לפניך, but since he handed over the ox to the beis din, it is considered being mazik the owner b'yadayim, for which he is liable as a mazik. This is only because the beis din having the ox gives them the ability to judge it, therefore he is a mazik for handing it over. But according to R' Yakov that they could judge it even not in its presence, he is not doing an act of damage by handing it over so he is not chayev.
Tosafos asks on rashi: If the act of handing over is considered a היזק ניכר, a recognizable damage, then even if he allows the beis din to take it without making an effort to hide it, he should be chayev. And if it is considered a היזק שאינו ניכר, a damage that is not recognizable in the object, he should not be liable even for handing it over?
Due to these questions, Tosafos deviates from rashi's approach, and explains that it is considered a recognizable damage and he is therefore chayev even for passively not taking measures to avoid the beis din from getting their hands on it. Therefore the rabbonon hold that he is chayev as a mazik even if the beis din grabs it from him without him handing it over, whereas R' Yakov holds that since they could judge it even not in it's presence, it is considered a non-recognizable damage, so he is not liable.
The Mishneh L'melech (gezeila 3:4, cited in rashash and gilyon mr"sha) asks on Tosafos question, we can consider it a damage that is not recognizable which is at least chayev m'drabonon similar to being metamei the taharos of someone else? The Steiper (31) explains Tosafos question that the handing over the ox to beis din really should not qualify as a damage at all, rather it is a mitzvah to help the beis din obtain the ox. The responsibility here of the shomer is only due to the fact that he is a shomer who has chiyuvim to the owner. Being that he has chiyuvim to the owner, by handing over the ox to beis din, he may be succeeding in his responsibility to Hashem, but is failing in his responsibility to the owner. Therefore, Tosafos asks that if היזק שאינו ניכר לא שמיה היזק so that he can't be liable as a "mazik", he should be patur for handing it over to beis din since it is considered a mitzvah.
Rashi would answer this by saying that he may be obligated to Hashem to assist the beis din in getting the animal, but his responsibility to the owner [which is also recognized by Hashem] is to avoid beis din from getting the animal. Therefore by handing them the animal he is failing in his responsibility as a shomer. Since as a shomer he is in violation for helping the beis din get it, he can no longer claim to be justified by giving it to them and becomes a mazik on this act, so he is liable as a mazik.