Varuna was one of the oldest of the Vedic deities. Varuna may have been part of the first triad of gods known in the Vedic period—along with Mitra and Arya- man. A little later but still within the early Vedic period, they were replaced by Agni, Indra, and Surya.
Varuna was both an asura (demon) and a deva, leading to the notion that Varuna, ancient lord of justice (rita) and truth (satya), had a violent streak. There were accusations in the later myths that this violence was why Indra took away Varuna’s power.
In the early Vedas Varuna was the king of the earth and the sky, and the creator. He was also associated with Mitra, the ruler of the night—though in later Vedic hymns we find him as the chief of the adityas, thus an asura, and contrasted to Mitra, a deva and a ruler of the day.
Later when Indra took over the rulership of heaven, Varuna became the god of oceans, who rode on a makara, his fish or water monster vehicle. This phase was especially elaborated in the Puranas. He was presented as the father of Brahma, who created the whole world, and also of the sage Vasishtha, one of the seven Rishis (sapta-rishis). Like the more famous god of death and justice, Yama, one of the attributes of Varuna was a noose (nagapasa) by which he tied the guilty, a remembrance of his role of judge of the just and the unjust.