car slowed, check engine light came on - car misfired. on 2002 Mazda Protege5

engine sputtered...stopped car then started again, the engine revved and accelerated..was able to get car to slow...drove about 200 yards process repeated...but did not accelerate. I was able to drive home. Mechanic says it has a PO300 code but the car is driving fine. I had driven the car up a steep grade to and from and errand. I had a similar incciden occure several years back when I parked the car on a sleep misfired but resolved. Any ideas.??

Asked by for the 2002 Mazda Protege5