The problem may be electrical noise from the motor, or
you may have a wiring problem (an incorrect or intermittent connection).
Kira San’s comment “try to add a 100nF ceramic capacitor between the motor terminals” is directed toward suppressing electrical motor noise. As brushes make or break connections on a motor's commutator, arcs and sparks can occur. The capacitor will limit voltage rate of change thus suppressing some of that electrical noise.
CharlieHanson's comment (add a flyback diode across the motor terminals) is partly related to noise suppression but mostly to suppressing high voltage excursion that occurs when you shut off motor power. While the motor is running, the magnetic field in it stores ½ L i² joules of power. When current stops suddenly, those joules of power convert to a high voltage spike. A flyback diode acts as a near-short to absorb that spike. The cathode (cross-bar) of the flyback diode attaches to the high side of the motor voltage, as shown in the circuit diagram of the project you linked to on electroschematics.com.
Re “you are using a resistor with that LED, yes? I'll overlook the fact that it's the wrong way round in the schematic!”, if the LED is wired backwards as shown in your drawing, it won't turn on – which is a good thing, because without a resistor (say 300-3000 Ω) in series with the LED, enough current may flow to damage the Uno or the LED. Turn the LED around on the schematic (and on your wiring setup if you didn't already), and add a series resistor.
Edit: A comment says, “Don't have a diode either :S Will an LED work instead?”. LEDs typically have rather low reverse-voltage ratings – 4 to 5 volts. You could put two or three in series and if they don't burn up you're ok for this experiment. But in production, don't depend on LEDs as flyback diodes except where it doesn't matter what happens.
- Gerben's comment, “What is that capacitor doing there? Slow start?” refers to the 100 μF capacitor shown between transistor base and emitter. In conjunction with the 1KΩ resistor from D4, that gives RC=0.1 second, so the transistor will take an appreciable amount of time to turn on. This has a couple of consequences: PWM control may be less effective (at low duty cycles, PWM depends on short, high-current pulses, to overcome stiction etc) and the transistor will run hotter. If it's a big power transistor, ok. If it's a small switching transistor intended for full-on or full-off, no.
Edit: A comment refers to a fan speed controlled temperature page at electroschematics.com. That page shows a BD139 power transistor, and says the 100 μF capacitor between transistor base and emitter eliminates some motor noise. Thus it falls into the “big power transistor, ok” category. Well, more or less ok. A heat sink may be needed on the transistor and the capacitor probably doesn't need to be that big; eg try 10 μF instead of 100.
- An ordinary 9V battery easily supplies a dozen milliamps, but current draw larger than that quickly depletes it. See eg 9V Alkaline tests at powerstream.com and my answer to a previous question, Using Arduino Micro With 12V Buzzer that's somewhat related. The motor shown (TD599839) is rated at 35 mA at 5.9 V no-load, so will draw say 50 mA no-load from a 9V battery and will try to draw several times that if loaded; ie it will overstress an ordinary 9V battery. In brief: Use a wall-wart or equivalent, or a big battery, rather than a small 9V battery when running motors.