What was the cause of disobeying order?
You said, ..
Yet he still went against a direct order of god. Why? Is he stupid or something?
I think, The Main cause of Shaitain which influence him to disobey the direct order of Almighty Allah, The creator of All, The Owner of All, Subhanahu-wa-ta'la was arrogance i.e pride, vanity, egoism. I would like to put emphasis on the word egoism. This word is more closer to his situation. The indicence of his disobiedience and arrogance is reflected in this ayat
And when We said to the angels, "Prostrate before Adam"; so they prostrated, except for Iblees. He refused and was arrogant and became of the disbelievers. source
It is clear from this ayat is, He was proud and arrogant and refused to prostrate Adam.
Cause of his arrogance
The cause of his arrogance was, he thought and considered himself better than Adam (indeed this is the main cause of creation of arrogance and pride in most of us) because, He was made from Fire and Adam was made from earth/clay. This cause is narrated by himself!. Quran quoting his words:
[ Allah ] said, "What prevented you from prostrating when I commanded you?" [Satan] said, "I am better than him. You created me from fire and created him from clay." source
I was also told that, He said, Fire always go up and clay go down even if you throw it up.
Huzzatul Islam (The proof of Islam) Imam Gazzali (Rahimahu-Allah) wrote in his Great book (Ih-ya-u-uloom-id-din), Once prophet Musa (A.S) saw Saitain and Saitain said,"I want to repent, please seek forgiveness for me from Allah". Allah said in reply to Musa's request to forgive him, "Say him, to prostrate Adam's Grave". Hearing this, He strong and quickly refused to do so, saying "I didn't prostrate living Adam, How can I prostrate Adam after his death. It's impossible"
Another cause was, As He was made the leader of Angels because of his excessive worship source (It is said that, there is no place in the heaven where saitain did not give sajdah to Allah) and Jinn and from his knowledge he forseen that, Mankind is going to be the Kalif of Allah in earth and he thought, He will no longer be preferred.
Did God make a pact?
So god and the devil made a pact...
No, never, God didn't make a pact. A pact can be made with equal parties. There is absolutely no power of Saitain in front of Allah. He fear Allah too muchlink and he knows his power also. He just seek a time period before his punishment and Allah gave him this chance. (Allah wants to test mankind with him)
[Satan] said, "Reprieve me until the Day they are resurrected." source
and Allah answered:
[ Allah ] said, "Indeed, you are of those reprieved." 7:15
Allah has given him chance, so that We can be tested.
And Allah knows all and best, He is the all-knower.