The King was the most powerful person, but his power was sometimes rivaled by the High Priest.
Answer:
The power of the king was never rivaled by that of the Kohen Gadol ("high priest"). They had two different spheres of power (see Related Question).
When the Kohen Gadol was the most powerful leader, it was for one of two reasons:
1) There was no king at the time; or -
2) The king and the Kohen Gadol were the same person.
The above two situations occurred during certain parts of the Second Temple era:
1) There was no king for the first couple of centuries of the Second Temple. The Kohen Gadol held temporal power only for the first several decades of that time; after that the office of the Nasi was created; and the Nasi was invariably a Torah-scholar.
2) The king and Kohen Gadol were the same person during the one century when the Hasmoneans held power; not before or after.