Mohini distributing the Amrita to the Devas (left), while the Asuras look on.
The Amrita The earliest reference to a Mohini-type goddess appears in the Samudra manthan episode of the 5th century BCE Hindu epic Mahabharata.  The Amrita, or nectar of immortality, is produced by the churning of the Ocean of Milk. The Devas (demi-gods) and the Asuras (demons) fight over its possession.  The Asuras contrive to keep the Amrita for themselves, angering the Devas. Vishnu, wise to their plan, assumes the form of an “enchanting damsel”. She uses her allure to trick the Asuras into giving her the Amrita, and then distributes it amongst the Devas. Rahu, an Asura, disguises himself as a god and tries to drink some Amrita himself. Surya (the sun-god) and Chandra (the moon-god) quickly inform Vishnu, and he uses the Sudarshana Chakra (the divine discus) to decapitate Rahu, leaving the head immortal.  The decapitated body becomes Ketu. Rahu and Ketu are both regarded as celestial bodies that assume one’s destiny. The other major Hindu epic Ramayana (4th century BCE) narrates the Mohini story briefly in the Bala Kanda chapter.  This same tale is also recounted in the Vishnu Purana four centuries later. 
In the original text, Mohini is referred to as simply an enchanting, female form of Vishnu. In later versions, Mohini is described as the maya (illusion) of Vishnu. Later still, the name of the avatar becomes Mohini from the original phrase describing his deliberate false appearance (mayam ashito mohinim).  Once the Mohini legend became popular, it was retold, revised, and expanded in several texts. The tales of Mohini-Vishnu also increased among devotional circles in various regions.  The same expanded Mahabharata version of the story is also recounted in the Bhagavata Purana in the 10th century CE.  Here, Mohini becomes a formal avatar of Vishnu. 
This legend is also retold in the Padma Purana  and Brahmanda Purana. In the Brahmanda Purana, however, Vishnu-Mohini simply, after mediation upon the Great Goddess Maheshvari, acquires her form to trick the thieving asuras.