Fire and flames are a terrain effect. Your character, monsters and objects will take damage from Burning when on fire.
All gasses but steam, darkness, and healing spores will burn, and Explosive gas explodes.
There are many types of terrain that can burn, including the carpet of poisonous tendrils created by a Potion of Creeping Death. This can make it useful as an improvised fuse.
The player has three primary ways of setting fire directly: Potions of Incineration, a Staves of Firebolt, and Incendiary Darts. Throwing any item into a lava filled square creates a bit of flame which will ignite flammable gases or terrain (webs or rope bridges)
There are also several ever-burning monsters in the game, including the Salamander and Will-o-the-wisp.
There are a few different kinds of fire in the game: Fire is just your standard fire; crackling flames are created when an item (except for the Amulet) falls in lava, and greasy flames when a non-fire-immune monster dies in lava. Flashes of fire are white flames; they are created when an incendiary dart hits a tile with no monster and no flammable terrain on it. (They only last one turn.) Torches and braziers are essentially everlasting fire in walls: they can't be walked into but will ignite gases. Sacrificial flames are created when you sacrifice a monster in one of the key holders. Infernal fire is created by flamedancers, and the ground underneath them, after the fire has gone out, will turn into obsidian. Sulfurous flames are created from brimstone. Explosions are considered fire, too.