Entering Eä at the beginning of time, the Valar and Maiar tried to build and organise the world according to the will of Eru. Each of the Maia spirits was associated with one of the powerful Valar whom they served; for example, Ossë and Uinen, who were spirits of the sea, belonged to Ulmo, the Vala who was lord of the oceans. Sauron was prominent among the Maiar who served Aulë the Smith, the great craftsman of the Valar. As a result, Sauron came to possess great knowledge of the physical substances of the world, forging, and all manner of craftsmanship—emerging as “a great craftsman of the household of Aulë”. Sauron would always retain the "scientific" knowledge he derived from the great Vala of Craft: “In his beginning he was of the Maiar of Aulë, and he remained mighty in the lore of that people.” Sauron's original name was probably Mairon (the Admirable), but this name was changed to Sauron after he was suborned by Melkor. However, during the First Age Sauron continued to call himself Mairon.
Within the vast spaces of Eä, the Valar eventually concentrated their efforts on the realm of Arda, the Earth, where Elves and Men were destined to appear as the “Children of God.” But Melkor, who would later be known as Morgoth the Black Enemy, had also arrived in Arda. Fiercely desiring to become its supreme lord, he opposed the other Valar, who remained faithful to Eru and tried to carry out the Creator’s designs. Around this time, Sauron fell victim to Melkor’s corrupting influence: “In the beginning of Arda Melkor seduced him to his allegiance.”
As for Sauron's motives, Tolkien noted that "it had been his virtue (and therefore also the cause of his fall …) that he loved order and coordination, and disliked all confusion and wasteful friction." Thus "it was the apparent will and power of Melkor to effect his designs quickly and masterfully that had first attracted Sauron to him."
For a while, Sauron apparently kept up the pretence that he was a faithful servant of the Valar, all the while feeding Melkor information about their doings. Thus, when the Valar made Almaren as their first physical abode in the world, “Melkor knew of all that was done; for even then he had secret friends and spies among the Maiar whom he had converted to his cause, and of these the chief, as after became known, was Sauron.”
Almaren was destroyed by Melkor, and the Valar established a new abode in the Uttermost West: the Blessed Realm of Valinor. They still did not perceive Sauron’s dubious loyalties, for he too became “a being of Valinor”.
At some point, Sauron left the Blessed Realm and went to Middle-earth, the central continent of Arda. In one text, Tolkien wrote of Sauron that “in Valinor he had dwelt among the people of the gods, but there Morgoth had drawn him to evil and to his service”. It would seem that Sauron now definitely sided with Melkor. No longer just a spy and secret sympathizer, he deserted his service to the Valar and openly joined their great enemy: “Because of his admiration of Strength he had become a follower of Morgoth and fell with him down into the depths of evil.”