Commentary for Horayot 1:1
הוֹרוּ בֵית דִּין לַעֲבֹר עַל אַחַת מִכָּל מִצְוֹת הָאֲמוּרוֹת בַּתּוֹרָה, וְהָלַךְ הַיָּחִיד וְעָשָׂה שׁוֹגֵג עַל פִּיהֶם, בֵּין שֶׁעָשׂוּ וְעָשָׂה עִמָּהֶן, בֵּין שֶׁעָשׂוּ וְעָשָׂה אַחֲרֵיהֶן, בֵּין שֶׁלֹּא עָשׂוּ וְעָשָׂה, פָּטוּר, מִפְּנֵי שֶׁתָּלָה בְבֵית דִּין. הוֹרוּ בֵית דִּין וְיָדַע אֶחָד מֵהֶן שֶׁטָּעוּ, אוֹ תַלְמִיד וְהוּא רָאוּי לְהוֹרָאָה, וְהָלַךְ וְעָשָׂה עַל פִּיהֶן, בֵּין שֶׁעָשׂוּ וְעָשָׂה עִמָּהֶן, בֵּין שֶׁעָשׂוּ וְעָשָׂה אַחֲרֵיהֶן, בֵּין שֶׁלֹּא עָשׂוּ וְעָשָׂה, הֲרֵי זֶה חַיָּב, מִפְּנֵי שֶׁלֹּא תָלָה בְּבֵית דִּין. זֶה הַכְּלָל, הַתּוֹלֶה בְעַצְמוֹ, חַיָּב. וְהַתּוֹלֶה בְּבֵית דִּין, פָּטוּר:
If beth-din ruled to transgress one of all the mitzvoth written in the Torah [If they said: You are permitted to do something, deliberate transgression of which is punishable by kareth], and an individual went and transgressed unwittingly by their ruling, [(as opposed to an instance in which he did not transgress by the ruling of beth-din, as when beth-din ruled that chelev (forbidden fats) is permitted and he mistook chelev for shuman (permitted fats) and ate it, in which instance he is liable, not having eaten it by the ruling of beth-din)] — whether they transgressed and he transgressed with them or they did not transgress [by their ruling], he is exempt [and they are liable, for beth-din bring the offering only for unwittingness in ruling, the act being dependent on the congregation, and the ruling upon beth-din], (he is exempt) because he relied upon beth-din. [Our Mishnah is in accordance with R. Yehudah, who says: An individual who transgressed by the ruling of beth-din is exempt (from a sin-offering). The halachah, however, is in accordance with the Rabbis, who say that an individual who transgressed by the ruling of beth-din is liable. He is not exempt unless the transgressors are the majority of the dwellers of Eretz Yisrael or the majority of the tribes, in which instance beth-din bring a bullock of forgetfulness of the congregation and those who transgressed by their ruling are exempt.] If beth-din ruled (wrongly) and one of them knew that they were mistaken or if he were a Torah scholar eligible to rule and he went and transgressed by their ruling — whether they transgressed and he transgressed with them or they did not transgress and he transgressed, he is liable, because he did not rely upon beth-din (in transgressing). [And even though he sinned deliberately, knowing that beth-din had erred and, notwithstanding this, transgressed by their ruling, and a deliberate transgressor is not subject to an offering, the Gemara states that he is (considered) unwitting, having thought that it was a mitzvah to abide by beth-din's ruling, even though he knew that they had erred.] This is the rule: One who relies upon himself (in transgressing) is liable [to bring an offering (including one who "kicks" against the ruling (of beth-din), one whose way is not to act in accordance with their ruling, and who acted in accordance with their ruling, not because he relied upon their ruling but because it appeared to him that it was permitted, he is liable)]; one who relies upon (the ruling of) beth-din is exempt.
Bartenura on Mishnah Horayot
English Explanation of Mishnah Horayot
If the court ruled [in error], and one of them knew that they had erred, or a disciple who was himself fit to rule on matters of law, and [one of these] proceeded and acted in accordance with their ruling, whether they acted and he acted with them or they acted and he acted after them or even if they did not act and he acted, he is liable, since he did not rely upon the court.
This is the general rule: he who is [in a position] to rely upon himself is liable, and he who relies upon the court is exempt.
Our mishnah discusses a person who follows a ruling that a court made in error, and thereby accidentally transgresses a commandment.
Section one: If a person follows a court ruling that was made in error, and thereby transgresses a negative commandment which carries with it the liability to bring a sin-offering [when done unintentionally], he is not liable, since this was not his error but their error. This rule is true whether he acted together with them, after them or even if he transgressed and the court itself did not even perform the transgression. In other words, even if he relied on their words and not their concrete example, he is exempt. This is not considered to be an unintentional sin that he has committed and therefore he need not bring a sin-offering.
Section two: However, if the person who committed the transgression was a member of the court who knew that his fellow judges were in error, or was a student who was fit to be a member of the court and he knew that the court was in error, he is liable if he acts according to the wrong ruling. Note that this person is still considered to be an unintentional sinner and not an intentional one. His mistake was that he thought that he should listen to the court, even if he knew they were wrong. Since he did not need to rely on the court, but was fit to rely on his own ruling, he is liable, at least as an unintentional sinner, for his own transgression. He therefore needs to bring a sin-offering.