Terumot, Chapter Three, Mishnah Six
Below in mishnah seven we will learn that bikkurim, first fruits, should be taken from produce before one takes out the terumah. Today we learn that if one nevertheless gives the offerings in the wrong order, his actions are valid.
He who gives terumah before first-fruits, or first tithe before terumah, or second tithe before first tithe, although he transgresses a negative commandment, that which he has done is done, for it is said: You shall not delaying the skimming of the first yield of your vats (Exodus 22:28).
In all of these cases the person gives the agricultural offerings in the wrong order. He should have set aside first fruits while the fruits were still attached to the ground, but instead, what he did was first harvest them, then take out terumah and only afterwards set aside the bikkurim. Alternatively, he separated the tithes before the terumah or the second tithe before the first tithe. In all of these cases his actions are valid.
One who took terumah out before the bikkurim has transgressed the negative commandment of delaying the giving of his first fruits, which is how this verse in Exodus is understood by the rabbis. However, despite the fact that this is a transgression, he still performed a valid act of separating terumah and he can eat the produce.