The article The Fall of the Human Race provides a detailed discussion regarding this foundational issue.
But the devil said: Suffer me, and I will tell thee how I was cast down into this place and how the Lord did make man.... And when I came from the ends of the earth Michael said: Worship thou the image of God, which he hath made according to his likeness. But I said: I am fire of fire, I was the first angel formed, and shall worship clay and matter? And Michael saith to me: Worship, lest God be wroth with thee. But I said to him: God will not be wroth with me; but I will set my throne over against his throne, and I will be as he is. Then was God wroth with me and cast me down, having commanded the windows of heaven to be opened. (Gospel of Bartholomew 4:52,54-55)