In the Roman Kingdom, the King of Rome was the principal executive magistrate with absolute power. The king was the chief priest, lawmaker, judge, and sole commander of the army. On the death of the king, his power reverted to the Senate, which then appointed an Interrex to serve during the election of the next king. When the Roman Republic was created in 509 BC, the king's powers were transferred to the magistracy of consuls—of which there were two appointed each year. The king ruled for an average of 35 years, and the magistracy was not hereditary. According to legend the first king was Romulus, the mythical founder of Rome.