Stewart went into a spin on Lap 45 and fell from first to 19th place, but climbed back into contention in time to capitalize when Gordon slid off the track with two laps to go -- and took the checkered flag 2.460 seconds in front of Denny Hamlin.
It was Stewart's third win of the season, his fourth at Watkins Glen and the 32nd of his "Cup" career.
"Jeff and I by far had the best two cars," said Stewart. "We kept the pressure on Jeff and hoped he made a mistake and that's what happened."
Gordon had the pole for the start of the race, based on points, after qualifying was rained out Friday.
Jimmie Johnson, Ron Fellows and Robby Gordon completed the top five. Points leader Jeff Gordon finished ninth.
The next race in the series is set for Aug. 19 at the Michigan International Speedway.