There are quite a few things that can cause the problem you are experiencing. It could be anything from a clogging fuel filter, bad oxygen sensors, to an intake leak. I would suggest that you purchase or rent a scan tool from a local parts house or take it to a garage that has an even better scan tool. Either can help to identify the problem. Many parts stores offer to scan it for free (AutoZone, Pep Boys, et. al.).
I would think that it may be likely to be something fairly inexpensive (though that certainly may not be the case). Hopefully, a good tune up might even fix the problem. If the check engine light was flashing, it may have been telling you that your car was misfiring and it could be a matter of a faulty ignition coil, spark plugs, or ignition wires. I do suggest the scan and perhaps a fuel pressure test to get you started on diagnosis.