I turn my ignition and my wagon just dies?

Well I was just on my way out and I keep my wagon garaged daily. So I get in and I turn my key in the ignition and right away it starts then it dies???? So I try again and it starts but then my check engine light turns on for a bit then goes away. So i have the car sitting running for a little to warm up, then I turn it off. Then I wait about 5 minutes and try to start it again, and the same things happen. I turn the key its starts then it dies quickly! then I do it a second time then it starts, but this time with no check engine light on. What might be the problem? Need help ASAP! Thanks.
Comments
Fiddle with the switch a bit- does it do it if you let the key come back easy versus snapping back from the start position?