Mass and rest energy are the same thing, just expressed in different units. It might make things easier for you if you simply forget about "mass" altogether for a moment, and focus instead on energy:
The total energy ##E## of a closed system is a special quantity because it's conserved. That's why we care about it.
Now, a system's total energy is the sum of its rest energy ##E_0## and its kinetic energy ##E_k##:
##E = E_0 + E_k##.
You can see that when ##E_k = 0##, we have ##E = E_0##. So rest energy is just the total energy of a system as measured in its own rest frame.
Since mass and rest energy are fundamentally the same thing, your question can be rephrased: "Which came first: the total energy of a system, or the total energy of a system as measured in its rest frame?"
The question makes no sense.