The Gemara derives from the Pasuk that Shabbat is Kodesh (sanctified), but Melacha (work) done in violation of Shabbat is not Kodesh and is not forbidden to benefit from. This is true on the level of D'Oraita (Torah law), but the Hachamim instituted a "K'nas" (penalty) to forbid benefit from prohibited actions done on Shabbat.
The severity of the penalty depends whether it was done B'Shogeg (unintentionally) or B'Mezid (intentionally). The Shulhan Aruch rules that Melacha done B'Shogeg is forbidden to everyone on Shabbat and is permitted immediately upon Mosa'eh Shabbat. If the Melacha was done B'Mezid, the violator is barred from ever benefiting from it, but others may benefit on Mosa'eh Shabbat.
One application of this Halacha was presented in a previous Daily Halacha, in a case where a woman removed a cover from a pot on the Blech and discovered that its contents were not cooked. If she returns the lid to the pot, she is in violation of the Melacha of Bishul (from the Torah), and therefore, the food is forbidden from benefit to everyone, even if she committed the violation unintentionally.
The question arises whether the Halacha would be the same in a case where the woman discovered the food was partially cooked-to the degree of Ma'achal Ben Drusai (one-third cooked), which is edible only in extreme circumstances. The Shulhan Aruch rules that even a food cooked to this degree is subject to further cooking, and clearly it was prohibited for her to return the cover. Nevertheless, the Mishna Berura (318:2) establishes a general principle that although the Halacha prohibits an action, whenever there is a legitimate disagreement between the Poskim, the lenient opinion can be relied on to permit the food, B'diavad-after the fact. In this case, there is the minority opinion of the Rashba that considers such a food fully cooked and not subject to the prohibition of further cooking. Even though the Halacha is not in accordance with the Rashba, he can be taken into account to permit eating the food after the woman returned the cover.
Hacham David in his Halacha Berura brings this principle. The classic application would be if a woman mistakenly reheated cold soup on the Blech. While clearly this is prohibited from the Torah, it does not render the soup forbidden, because of the minority opinion of the Rambam who holds that there is no prohibition to reheat cooked cold liquids.
It is forbidden to benefit on Shabbat from even an unintentional violation of Shabbat, unless there is a legitimate, lenient minority opinion, which can be taken into account B'diavad-after the fact.