Orlah, Chapter 2, Mishnah 8. This Mishnah raises the question: what is the law when leaven falls into a dough twice - permitted leaven first, and forbidden leaven afterward?
The words of the Mishnah and its two stages:
"Se'or shel chullin shenafal l'toch isah v'yesh bo k'dei l'chametz" - leaven of ordinary, unconsecrated food fell into a dough of ordinary food, and it contains enough to leaven the entire dough. In practical terms, this leaven is effective.
"V'achar kach nafal se'or shel Terumah o se'or shel kilayim v'yesh bo k'dei l'chametz" - before the leavening actually took effect, leaven of Terumah, which is forbidden to a non-kohen, or leaven of kilayim, which is forbidden to everyone, fell into the dough, and it too contains enough to leaven it.
Even though the permitted leaven fell in first, since it did not have time to complete the leavening process, and now leaven of a forbidden substance fell into the dough, the dough is forbidden.
The reason for the law:
Because of the forbidden leaven, the dough rises more quickly. It turns out that there is a benefit here coming from the power of the forbidden leaven, since on the strength of the permitted leaven alone the dough would not have risen at this speed - and that reason is enough to create a prohibition.
In summary: the fact that permitted leaven fell in first does not permit the dough, since as long as the leavening was not complete, it was the forbidden leaven that fell in afterward which sped up the process, and that benefit renders the dough forbidden.