hello there I'm new to this forum and i was looking for some help online. the problem that i have with my expedition is that it wont start

and after a few minutes it does

lemme tell you the story in detail OK so I'm driving down the freeway and my service engine soon light shows up.... OK so i pay no attention to it and 3 days latter it goes away then 3 days latter it comes back it went like that for a month. one day i was going to work and i tried to start my car it dint want to start it just cranked and the truck dint want to fire up so i gave it a little gas and it fired up but when i let go of the throttle the engine would die

so i tried it 10 min latter and it started like if it had nothing wrong with it. so i took it to work for about two weeks then one day i tried to start it and the same problem but this time if i tried to give it some gas it wouldn't do any thing it just sat there and cranked. so i remove the air filter thinking maybe there something blocking air from going into the engine i dint see nothing,i put everything together i go to start the truck and it fires right up but now the check engine light went away i shut it down and try to fire it up again and it wont start it just cranked! its driving me nuts if any one can help me out i would really appreciate it thank you all
my expedition is a 2001 xlt 5.4 76000 miles