Sometimes a combatant in a melee lets her guard down. In this case, combatants near her can take advantage of her lapse in defense to attack her for free. These free attacks are called attacks of opportunity.
You threaten all squares into which you can make a melee attack, even when it is not your action. Generally, that means everything in all squares adjacent to your space (including diagonally). An enemy that takes certain actions while in a threatened square provokes an attack of opportunity from you. If you’re unarmed, you don’t normally threaten any squares and thus can’t make attacks of opportunity.
Most creatures of Medium or smaller size have a reach of only 5 feet. This means that they can make melee attacks only against creatures up to 5 feet (1 square) away. However, Small and Medium creatures wielding reach weapons threaten more squares than a typical creature. In addition, most creatures larger than Medium have a natural reach of 10 feet or more.
Two kinds of actions can provoke attacks of opportunity: moving out of a threatened square and performing an action within a threatened square.
Moving out of a threatened square usually provokes an attack of opportunity from the threatening opponent. There are two common methods of avoiding such an attack—the 5-foot-step and the withdraw action.
Some actions, when performed in a threatened square, provoke attacks of opportunity as you divert your attention from the battle. Actions in Combat notes many of the actions that provoke attacks of opportunity.
Remember that even actions that normally provoke attacks of opportunity may have exceptions to this rule.
An attack of opportunity is a single melee attack, and you can only make one per round. You don’t have to make an attack of opportunity if you don’t want to.
An experienced character gets additional regular melee attacks (by using the full attack action), but at a lower attack bonus. You make your attack of opportunity, however, at your normal attack bonus—even if you’ve already attacked in the round.
An attack of opportunity "interrupts" the normal flow of actions in the round. If an attack of opportunity is provoked, immediately resolve the attack of opportunity, then continue with the next character’s turn (or complete the current turn, if the attack of opportunity was provoked in the midst of a character’s turn).
If you have the Combat Reflexes feat you can add your Dexterity modifier to the number of attacks of opportunity you can make in a round. This feat does not let you make more than one attack for a given opportunity, but if the same opponent provokes two attacks of opportunity from you, you could make two separate attacks of opportunity (since each one represents a different opportunity). Moving out of more than one square threatened by the same opponent in the same round doesn’t count as more than one opportunity for that opponent. All these attacks are at your full normal attack bonus.