Rules and notation
A repetition is a position, not a move
Threefold repetition means the same position has occurred three times, not that the same move was played three times. Match the side to move, piece types, colors, squares and legal options, including castling or en passant eligibility.
Worked example
Position in text
White to move. White: king a1, knight b1. Black: knight g8, king h8.
FEN: 6nk/8/8/8/8/8/8/KN6 w - - 0 1
Play 1. Nc3 Nf6 2. Nb1 Ng8 3. Nc3 Nf6 4. Nb1 Ng8. The starting arrangement with White to move appeared initially, after 2…Ng8 and after 4…Ng8. White can claim on turn. Under FIDE rules, a third occurrence can also be claimed by recording the intended move without making it and declaring the intention to the arbiter. Fivefold repetition ends the game automatically.
A plausible mistake
A rook that moved back need not restore the original position. Neither does the turn switch, or the disappearance of an en passant option that was genuinely legal at the first occurrence.
Try it yourself
Position in text
White to move. White: king e1, rook h1. Black: king e8.
FEN: 4k3/8/8/8/8/8/8/4K2R w K - 0 1
In the second diagram, White starts with kingside castling rights. Play 1. Rh2 Ke7 2. Rh1 Ke8 3. Rh2 Ke7 4. Rh1 Ke8. How many times has the final position appeared?
Check your answer
Twice: after 2…Ke8 and after 4…Ke8. Initially White could castle; after moving the rook that option is lost. The initial position does not count toward a claim for this final one.