The sage Gautama had three sons known as Ekata, Dvita and Trita.

Once these three brothers went to a sacrifice, participated as priests and got money. Trita got more than his brothers since he was more competent. While returning home, the two elder brothers pushed Trita into a well and ran away with his wealth. Trita prayed to the Viśvedevas (or Aśvinīdevatās) and got out through their grace. He also cursed his brothers to become wolves!

According to another version (vide Skandasvāmi’s commentary on Ṛgveda 1.105.1) Trita fell into a well when pursued by wolves. There, he saw a creeper, imagined it to be the soma creeper and mentally performed a Soma sacrifice. Various gods, along with Bṛhaspati (their preceptor), appeared before him, granted him all the boons he asked for and also rescued him.

The Ṛgveda, in another place vide 8.47.15) mentions that Trita-Āptya prayed to gods to be freed from the effects of bad dreams. Hence this mantra may be repeated as a sacred formula to ward off evil dreams.