2002 Malibu wants to stall at idle

My question is what is the possible cause of my car trying to stall when it idles? Here is the scenario. There was no problem with the car this morning. I was almost out of gas and filled it up. After filling up about two miles downt he road when I can to a stop sign or had to slow to an idle in traffic the car seemed like it wanted to stall. When I was driving at and speed other then idle it seemed fine. When I left work tonight the same thing. but this time when I got close to home the check engine light came on. I did check the gas cap and that seems fine. I was wondering what the possible cause could be. Thanks for any help.

Sounds like an idle air control valve.

Try cleaning it and the throttle body first.

Please post the fault code.