The wonderfully mysogenistic tale of Lilith as Adams first wife occurs in the Alphabet of Ben Sira written sometime between the 8th and 10th century A.D. But probably stems from earlier Judaic myths and going back as far as the Epic of Gilgamesh. However in the earlier myths lilith is more simply a form of demon similar to a succubus who generally conspires against Adam and his kin. Here's the tale from Alphabet:
He said, 'It is not good for man to be alone' (Gen. 2:18). He then created a woman for Adam, from the earth, as He had created Adam himself, and called her Lilith. Adam and Lilith began to fight. She said, 'I will not lie below,' and he said, 'I will not lie beneath you, but only on top. For you are fit only to be in the bottom position, while am to be in the superior one.' Lilith responded, 'We are equal to each other inasmuch as we were both created from the earth.' But they would not listen to one another. When Lilith saw this, she pronounced the Ineffable Name and flew away into the air. Adam stood in prayer before his Creator: 'Sovereign of the universe!' he said, 'the woman you gave me has run away.' At once, the Holy One, blessed be He, sent these three angles to bring her back.
"Said the Holy One to Adam, 'If she agrees to come back, fine. If not she must permit one hundred of her children to die every day.' The angels left God and pursued Lilith, whom they overtook in the midst of the sea, in the mighty waters wherein the Egyptians were destined to drown. They told her God's word, but she did not wish to return. The angels said, 'We shall drown you in the sea.'
"'Leave me!' she said. 'I was created only to cause sickness to infants. If the infant is male, I have dominion over him for eight days after his birth, and if female, for twenty days.'
"When the angels heard Lilith's words, they insisted she go back. But she swore to them by the name of the living and eternal God: 'Whenever I see you or your names or your forms in an amulet, I will have no power over that infant.' She also agreed to have one hundred of her children die every day. Accordingly, every day one hundred demons perish, and for the same reason, we write the angels' names on the amulets of young children. When Lilith sees their names, she remembers her oath, and the child recovers."
The earliest reference is in the prologue to Gilgamesh:
"because during that time
a dragon had built its nest at the foot of the tree
the Zu-bird was raising its young in the crown,
and the demon Lilith had built her house in the middle.
But Gilgamesh, who had heard of Inanna's plight,
came to her rescue.
He took his heavy shield
killed the dragon with his heavy bronze axe,
which weighed seven talents and seven minas.
Then the Zu-bird flew into the mountains
with its young,
while Lilith, petrified with fear,
tore down her house and fled into the wilderness"
http://ccat.sas.upenn.edu/~humm/Topics/Lilith/alphabet.html
http://ccat.sas.upenn.edu/~humm/Topics/Lilith/
http://www.webcom.com/~gnosis/lillith.html
~Raithere