To retreat is, technically, to run away from the enemy. Retreat can take many forms, but is generally undesirable in battle.
The most obvious form of retreat is the rout (pronouced rowt), which represents a complete loss of control and panicked flight from the battlefield. Soldiers who have been routed typically cannot be rallied, and are lost to the field. It is a military maxim that panic spreads, and once troops are panicking and running, they aren't likely to stop for a good long while. There are many period references to routed troops throwing away their weapons to run faster.
The tactical withdrawal is one of the most difficult manuevers for a commander to execute correctly. This involves moving your troops away from the enemy in such a way that they do not break and run, but also that they are vigiliant enought that the enemy has no chance to overwhelm them. When troops are actually involved in combat while this withdrawing, this is sometimes called a fighting retreat.
Similiar to the tactical withdrawal is the feigned retreat, used to great effect at the Battle of Marathon and the Battle of Hastings. This is where the troops retreat in the face of the enemy, trying to trick them into pursuit. When the enemy has taken the bait the retreating troops either quickly rally, turn and fight, or an allied force flanks the pursuers, or both.