123
4
F5
678
The Fighter threatens the 8 squares around him (it would be more squares if he had a reach weapon).
Let's say that the Fighter moves to engage a foe, and that foe is in space 2. If the foe moves into space 3 or space 1 (moving from one threatened square to another threatened square), the foe draws an Attack of Opportunity. If the foe moves backwards "above" space 2, or diagonal to the spaces above 1 or 3, he also draws an Attack of Opportunity.
The rule is: Any time a foe leaves a single threatened square, no matter if it is to another threatened square or to a square that is not threatened, the foe draws an Attack of Opportunity for each threatened square he leaves.
The way around this rule is to use the Five Foot Step rule (you do not draw an AoO if you only move one square), or to use the Withdraw maneuver.
You may find this helpful:
Attacks of Opportunity
123
4
F5
678
If the Fighter is combating a foe in space 2, and another foe runs past the Fighter, entering from above space 3, to space 5, to space 8, then exiting below 8, that second running foe draws three Attacks of Opportunity.
He draws one as he leaves Space 3....as he leaves Space 5...as he leaves Space 8.
But, unless the Fighter in the center has the Combat Reflexes Feat and a high DEX, the Fighter can only take one of those opportunities to attack the other running foe.
If, on the other hand, the same situation occurs, but the new running foe is actually moving each round in Five Foot steps, then the other foe does not draw AoO's. So, if the second foe enters space 3 and stops. Then, on the next round, uses a Five Foot step to move to Space 5. And on the next round uses a Five Foot step to enter Space 8. Then, on the next round, uses a Five Foot Step to leave Space 8, that second foe will draw no additional freebie attacks.