Dattatreya was the son of the sage Atri and his wife Anasuya. Anasuya, an archetypal chaste and virtuous wife, did severe Tapas (austerities) to beget a son equal in merits as Brahma, Vishnu and Shiva, the Hindu male trinity (Trimurti). Saraswati, Lakshmi and Parvati, the goddess trinity (Tridevi) and consorts of the male trinity, became jealous. They deputed their husbands to test her virtuousness.
The three gods appeared before Anasuya in the disguise of sanyasis (ascetics) and asked her to give them alms naked. Anasuya was perplexed for a while, but soon regained composure. She uttered a mantra and sprinkled water on the three mendicants, turning them into babies. She then breast fed them with her milk naked, as they wished. When Atri returned to his ashram (hermitage), Anasuya narrated the event, which he already knew through his psychic powers. He hugged the three babies to his heart, transforming them into a single baby with three heads and six arms.
As the triad of gods did not return, their wives got worried and rushed to Anasuya. The goddesses begged her forgiveness and requested her to return their husbands. Anasuya accepted their request. The Trimurti then appeared in their true form, before Atri and Anasuya, and blessed them with a son Dattatreya.
Though Dattatreya is considered a form of all the three deities, he is especially considered an avatar of Vishnu, while his siblings the moon-god Chandra and the sage Durvasa are regarded forms of Brahma and Shiva respectively