91 subaru legacy bucking

so I bought a car today, a 91 subaru wagon, automatic, for 1800 New Zealand dollars (around 1400 us) seemed real nice in the test drive but after buying it and driving it back to where we are staying (about a 30 minute drive) the check engine light came on. Now all of a sudden it is lurching forward a lot and seems to have something serious wrong, possibly the transmission is my guess/fear. Basically what happens is when pushing down the gas it takes a little bit extra to get it to do anything and then it lurches forward suddenly, if you let off the gas at all it slows down abruptly. If I stay on the gas it does fine after the initial lurch but it is almost impossible to keep a steady speed without it bucking a bit. Any ideas on what the problem is? Just moved to NZ 2 days ago and was ready to leave Auckland to start a new job in 2 days. When I bought it it (and car was running well) the gas was almost empty, problem started about 20 minutes after filling, not sure if that is relevant at all.