This one is not always completely understood, even by very experienced players. That is because the rule is a bit dry and players have memorized it in a slightly edited form.
This rule is actually called Triple occurrence of position in the Official Rules of Chess. It runs:
The game is drawn upon a claim by a player on the move when the same position is about to appear for at least the third time or has just appeared for at least the third time, the same player being on move each time. In both cases, the position is considered the same if pieces of the same kind and color occupy the same squares and if the possible moves of all the pieces are the same, including the right to castle or to capture a pawn en passant.
Position, Not Moves
Most players think of this rule as repeating the same move three times consecutively. But you will notice that there is no mention of repeating moves or the same position occurring consecutively.
Most often this draw will come about by the players repeating moves in order, since that is the easiest way to bring about a repetition of the same position. But it is possible to throw in other moves or to repeat the same position with a different move order, so it's a good idea to know the rule as it is stated in the rule book.
Here is an example of this triple occurrence of position draw:
White is in trouble, but the Black king is exposed. So White begins to check. The White queen moves to b8 to check. The Black king moves to g7, and the White queen moves to e5 to check again.
The Black king has to go back to the eighth rank, but he wants to avoid moving to f8, because then the White queen can move to h8 for checkmate. The Black king moves to g8. The White queen then moves to b8 for check. Note that this is the second time this position has occurred.
The Black king then moves to g7. The White queen checks at e5. The Black king escapes to g8 and the White queen again moves to b8 for check.
The intention of the triple occurrence of position draw is that the players are only wasting time if they keep coming back to the same position. The player who is trying to win must somehow come up with some sort of progress toward a checkmate, while the player who is trying to draw merely has to keep repeating the position.
You no doubt recognize this position by now. It is the third time it has occurred, and the game is therefore drawn.