My '98 Honda Accord vibrates every once in awhile for a few seconds. What could it be?

If I take my foot off the gas pedal right away it stops. If I don't, my check engine light goes on and stays on for a day or 2 and then goes off again on its own.

If you want to be really sure, go get it diagnosed. If the check engine light is on, there would definitelly by a fault code, which will tell you what the problem is. I recon its faulty knock sensor. But it can be anything - spark plug, coil, crank sensor… The list goes on and on.

It could be due to any one of 20 different problems. You should take it in to a mechanic who has the equiptment to properly diagnose and correct the problem.

Misfire most likely but a failing catalytic convertor or 02 sensor with mess with your fuel/air ratio.

For 40 bucks you can pick up an 0BD2 pocket scanner at Autozone, read the code and replace the bad parts.

BTW, if you ever need OEM Honda parts at a killer discount, check out an online store called BK Honda parts.
Built a whole new motor for the wife's accord for like $3,200.00, all brand new OEM stuff.