How are you defining "priest" if not a specialist in activities one might call religious?
It is impossible to answer this definitively, as each culture developed differently. I will speak to the earliest examples in the culture with which I am familiar: Ancient Egypt.
In Egypt, the roles we associate with priest were initially given to the king. It was his responsibility, as the living god, to travel up and down the Nile officiating various religious ceremonies, as well as ruling the kingdom. The role of priest originated as a stand-in for the king, as he could not be in every location as the population of Egypt grew. So, for Egypt at least, religion came first.