The Pyro is great at chipping away damage from other players without really killing them initially. The rockets he uses don't kill you outright, but leave you burning for some seconds. Fire is the Pyro's main asset, players "on fire" will burn for a short time and take some damage from it. The Incendiary Cannon is the Pyro's long-range weapon and is kool cuz it doesn't require reloading like the soldiers rockets. Use the same strategy as the soldier when handling cannon targeting, aim for the feet.
The Flamethrower is equally deadly cuz all it takes is a few seconds of flame to toast someone to a crisp. The heavier classes (Soldier, HWguy) are way too slow to escape your flame, so just cirle-strafe and toast them. Napalm grenades ("+gren2") were greatly increased in newer TF versions, they now explode nine times and ignnite everyone in the surrounding radius. Drop these in heavily populated areas, or on unsuspecting Sentries.
AGAINST
Avoid fire if possible. But don't let that consume you. If you're close to full health, you should be able to take the damage rather easily. Otherwise, head to water or the resupply room. The Flamethrower especially can be a pain, especially if you're a slow class. If a Pyro is on your tail, try to kill him first before he can toast you. This might mean firing backwards or bouncing grenades behind you. Otherwise, treat the Pyro just as you would the Medic or Demoman. His range weapon isn't very powerful, but he has some speed to compensate. Always remember that a Pyro never has to reload, which can be a sizeable disadvantage when facing one. And remember that the pyro's weapons won't kill you at once, so you'll have plenty of time taking him out if you're a heavier class than the pyro.