In Shmuel I, chapter 21, David requests provisions for his men from the priest Ahimelech, who agrees to give him the showbread on the condition that his men have kept themselves from women. Was this lawful?
The Talmud (M'nachos 96a) explains that David and his coterie were in mortal danger of starving at the time, which legally supersedes the prohibition against them eating showbread.
Another approach, mentioned by the Radak (ad loc.), is that the loaves were loaves from a korban todah (thanksgiving offering) that a non-priest could consume while in a state of purity (see also Malbim, ad loc., who suggests that the loaves were pseudo-t'ruma of todah loaves).
Context / background: This is a red herring used in the New Testament by Yoske in a logically flawed argument to excuse his followers from their desecration of Shabbos.
The showbread belonged entirely to the priests. It was not an offering, so it does not need to be treated in the same manner as their portion of the animals brought in the temple. They were entitled to use the bread as they saw fit, PROVIDED that it was respectful of its holy status.
In this story, they asked David if he and his men were ritually clean Shmuel I, 21:5. They responded in the affirmative. Thus, the priest was able to feed them with his portions of showbread from the Mishkan (tabernacle).