As Peyton Farquhar is getting executed, by hanging, as the noose is put around his neck he begins to dream about the possibility of escape. There are several clues in the narration that give the reader an idea that the escape is a fantasy. Once he drops into the water, he magically escapes the bullets that are fired at him. All the soldiers are shooting at him, and he does not get hit. He manages to swim a great distance with superhuman strength, he doesn't tire.
Once he reaches land, he runs and runs tirelessly trying to get home. He is chased and shot at, he does get shot, but is not seriously wounded, it is a miracle.
The biggest clue that he is dreaming is the fact that when he finally reaches his wife, he goes to wrap his arms around her, he does not get to feel her embrace, he is jolted back to the reality of the situation. He is dead, dangling from Owl Creek Bridge.
Some would say the the illusion begins in the first part. Near the end of it, he about to be hanged and he he focuses on the piece of wood slowly drifting down the stream--as if it's in slow motion. The ticking of his watch is slowed as well with it's clanking sound rather than the light tick it would have in real time. Those two aspects show that he could be slowly dying and time is slowing down for him.
Then in part 3 as he drops into the water, he feels "the pain of a sharp pressure upon his throat, followed by a sense of suffocation." These could be happening to him at that moment--but he slowed it all down dreaming that he escaped. Then at the end it is obvious when he reaches for his wife and then "he feels a stunning blow upon the back of the neck." This is when it makes sense that he was dreaming all along.