Engine stalls a few minutes after starting

I have a 98 outback sport. I recently changed the air filter. The next time I went to drive the car, it started fine, but after a few seconds of idling the engine just stopped and the check engine light came on. I tried this several times and the same thing happened. What could be doing this?

Make sure you didn’t loosen any of the wires going to the airflow sensor which, as I recall, you have to take off to change the filter. Also make sure the filter’s seated right and the housing snaps shut all the way.

Check the electrical connection to the MAF sensor.