Regardless of which role or race you choose, it is most important to stay alive. Many characters die long before they are able to reach that Amulet of Yendor.
NetHack is a turn-based game. NetHack is not Quake.
Always remember that NetHack is a turn-based game. You have as long as you need to consider your options, even in the heat of combat. In fact, when you find yourself in a sticky situation, it is wise to walk away from the keyboard while you think about what to do next. You can study your inventory (press [i]); that does not use any game turns. You could even save your game and consult some spoilers or ask the NetHack newsgroup.
As long as you do not touch the keyboard, all monsters will stay put; they will not hurry in and kill you. As soon as you move, use an item, or take some other action that uses time, the monsters have a turn too.
"Discretion is the better part of valor." Prefer escape to death.
In NetHack, there are no prizes for dying with honour. When a monster is giving you a hard time, it is seldom wise to take one last swing at it in the hope that it will die. It is much better to escape from the situation and return when you are more able to handle it. One reason why experienced players are fond of speed boots is that they enable you to run faster than most monsters.
Running is not the only way of escaping a dangerous situation. It's a good idea to carry a scroll or wand of teleportation so you can read it or zap yourself during emergencies. Teleporting yourself doesn't work on a no-teleport level, but anywhere in the dungeon above Medusa's level, unless it is the Quest or Sokoban, will allow you to teleport. However, teleporting the monster (by zapping it with the wand of teleportation) always works, even on a no-teleport level.
Most monsters won't follow you up or down stairs, though a few will. NetHack allows you to return to previous levels – if you reach the up staircase <, then you can escape most of the monsters on that level and return to a level with easier monsters. You can also escape through the down staircase > or zapping a wand of digging downward (so that you fall through the hole in the floor), though again, some monsters will follow you. If you drink a cursed potion of gain level, then you will "rise up, through the ceiling" and escape to the previous level.
If you cannot (or do not want to) flee, you could try to heal yourself. Prayer is effective if you are in reasonable standing with your deity, you haven't pestered them for help too recently, and they recognise that you are in need of healing. Their definition of "in need of healing" is either 5 HP or less, or 1/7 or less of your maximum HP. To pray, use the #pray command and hopefully your god will heal you completely. If you don't meet this definition, try some other means of healing, such as spells or potions. Once you are healed, you might survive long enough to kill some monsters or escape.
If you cannot escape, use "Elbereth".
An alternative survival strategy is to inscribe the word "Elbereth" on the ground. If you are unable to escape, using Elbereth might save your life. This prevents most non-human monsters from attacking you hand-to-hand, though they can still use ranged weapons, wands and spells. You can scribble "Elbereth" in the dust with your fingers, but then it is easy to erode, so it is better to engrave it with a wand of digging, and even better to burn it with a wand of fire or lightning. You can also use an athame (including the artifact Magicbane), but do not engrave Elbereth with any other weapon – its too slow and your weapon might dull and leave you with "Elberet". For full details on how Elbereth works, see Kate Nepveu's Elbereth FAQ.
If you cannot escape or use "Elbereth", use your strongest magic items.
If none of the above applies, and you feel you have to keep fighting, bring out the magic items or spells rather than hacking away with your weapon. Rays bounce, so take care to avoid being killed on the rebound, for example by choosing a wand to which you are already resistant.
Sometimes an indirect approach is better than melee.
Walking right up to a monster and whacking it with your melee weapon is not always the best approach. Some monsters, such as giant beetles or mumakil, hit hard but are slow enough that you should be able to keep your distance and kill them with ranged attacks. Others, such as floating eyes, are totally harmless until you hit them in melee, but have a nasty counter-attack (in this case, they paralyse you with their gaze, leaving you vulnerable to any newt that may appear). Pay attention to such monsters and think about alternative strategies for handling them.
Among the good ranged attacks are a bow and arrows, a crossbow and crossbolts, and powerful wands and spells such as magic missiles, fire, and cold. (Beware that wands and spells can bounce off walls; fire into a long corridor or use a wand or spell to which you are resistant. A force bolt from an experienced Wizard works well, but a wand of striking is relatively weak.) If you lack a good ranged-attack, use a weak one: throw junk weapons or rocks.