A period of three ages (about 2,900 years) followed. Melkor was imprisoned in the Halls of Mandos, and the Valar and Eldar dwelt together in the light of the Trees. In the darkness of Middle-earth, the Dark Elves who had not journeyed to Valinor still dwelt, and the Fathers of the Dwarves stirred. Men would not appear until some time after the end of the Years of the Trees.
These Years came to an end when Manwë released Melkor from his imprisonment. For a time, the Dark Lord pretended friendship with the Eldar, but he turned back to the darkness. After shining for 1495 Valian Years, they were destroyed by Ungoliant. During the Long Night, they stole the Silmarils and fled back to the north of Middle-earth. Seeking revenge, Fëanor led a great part of the Noldor out of Valinor and back to Beleriand.
So the Years of the Trees came to an end. At this time, the Valar made the Sun and Moon to give light to the World, and after 5000 Valian Years had passed, the Years of the Sun began. (Source: Tolkien Gateway)