With the lead group about 10 seconds up on the main body of riders, Cavendish was put into a solid position by Sky Procycling teammate -- and overall Tour leader -- Bradley Wiggins.
As the race entered its final half mile, Cavendish reeled in the leaders. It seemed Matt Goss and Peter Sagan had Cavendish boxed but Cavendish swung out to the right and blasted past for the stage win.
It was the 22nd Tour de France stage victory for Cavendish, who won the overall classification last year. He is tied with Lance Armstrong and Andre Darrigade for fourth most all-time in stage victories.
Cavendish covered the 138.3-mile run in 4 hours, 54 minutes, 12 seconds. The finish was so tight that dozens of riders were given the same time.
That also left Wiggins 2 minutes, 5 seconds ahead of another teammate, Christopher Froome. Vincenzo Nibali is 2:41 back and no other rider was within 5 minutes of Wiggins.
Saturday's Stage 19 is a 33.2-mile time trial from Bonneval to Chartres. The 99th Tour de France wraps up Sunday with a 74.6-mile ride into Paris.
Ron Burgundy interviews Peyton Manning on SportsCenter
Gal Gadot cast as Wonder Woman for 'Batman vs. Superman'