In The Silmarillion, Ungoliant was an evil spirit in the form of a spider who dwelt in Avathar in the First Age.
Ungoliant aided Melkor in his attack on the Two Trees of Valinor; she drained the Trees of their sap and poisoned them after Melkor wounded them. She drained dry the Wells of Varda, so that nothing remained of the Light that was before Sun or Moon, except in the Silmarils of Fëanor. She grew so large and powerful that Melkor himself was afraid. She and Melkor fled to Middle-earth to escape justice at the hands of the Valar by way of Helcaraxë, the ice bridge that linked Valinor to Beleriand.
After their flight from Valinor, Melkor gave her many gems of the Noldor, but withheld the Silmarils in his right hand. He refused to give them to the Great Spider to be devoured, for he desired them greatly. So great had Ungoliant's power grown through the consumption of the two trees and the Wells of Varda, that she had grown greater than Melkor and overpowered him.
Ungoliant might have either slain Melkor or encaged him in her darkness in the ensuing battle, but Melkor gave a great cry of fear that echoed over all of Beleriand, including the deep pits of Angband. Hearing his cry, the Balrogs came and saved their master, scourging the spider with their whips and causing Ungoliant to flee to the Ered Gorgoroth in Beleriand.
Her exact fate is not known, but it seems she starved in the forgotten south of the world and eventually devourered herself
She also gave birth to lesser spiders, the most notable one being shelob
who gives frodo
a hard time on LOTR.
“last child of Ungoliant to trouble the unhappy world”
Melkor: i have given you the light of Valinor and the Two trees. i shall keep the Silmarrils for my own
Ungoliant: Nay, with both hands you said you would give freely, the Silmarril's are mine.