Gordon, who started from the pole and led a race-high 51 laps, seemed to have his 10th road course victory in hand, but he spun out on his own heading into the first turn with Stewart a couple of car-lengths behind and finished ninth.
"I was driving hard," a dejected Gordon said after climbing from his No. 24 Chevrolet. "I just overdrove going into one. It was just stupid. I knew I had to push because Tony was really good."
For Stewart, who spun out in the same place while leading earlier in the race and dropping to 19th, it was his third victory in four races and sixth on a road course, tying him for second behind Gordon. Stewart has now won four of the last five races at Watkins Glen and finished second to Kevin Harvick a year ago.
"I saw Jeff lose it just like I lost it," Stewart said. "I had to keep fighting back."
Denny Hamlin finished second, Jimmie Johnson was third, Canadian road race ace Ron Fellows fourth and Robby Gordon fifth.
Dale Earnhardt Jr. suffered a big blow to his chances of making the Chase for the Nextel Cup championship with just four races remaining before the cutoff.
After complaining in practice about how bad his car was handling, Earnhardt turned things around in the race and was running up front much of the day. But while running third behind Gordon and Kurt Busch, the engine in the red No. 8 Chevrolet blew, ending his day on lap 63. He finished 42nd.
It was the fifth DNF of the season for Earnhardt, and four have been engine-related. He entered the day trailing Kurt Busch by seven points for the 12th and final spot in the standings. Only the top 12 after the first 26 races qualify to race for the title over the final 10 races of the season.
"We had an issue with the motor," Earnhardt said. "I think it was due to some of the downshifting I was making during practice. We had been having trouble with the car all week. We were doing well in the race, but I was downshifting to try and get some more power out of the car. I was hoping for a good showing and have something to be proud of. I'm kind of disappointed. We have a couple of races left and there's no telling what will happen in those."
Busch was caught speeding on pit road on his final pit stop but rallied to finish 11th.
Rookie Juan Pablo Montoya, who won a Busch Series race in Mexico and the Cup race at Sonoma in June, was bidding to become the first driver in NASCAR history to win three road races in a season. He failed in Saturday's Busch race, finishing 33rd after being involved in an accident, and on Sunday he had another altercation.
Montoya and Harvick got together with less than 20 laps remaining in the 90-lap event while both were running in the top 10, and ended up in a shoving match after their cars got banged up. Harvick finished 29th and Montoya was 39th.
It was the second road race for the boxier Car of Tomorrow, and there was plenty of action with eight cautions and even a red flag flying.
Stewart and Gordon had the staunchest cars all race. Gordon led the first 13 laps, then Stewart took over for the next 11 circuits around the 11-turn, 2.45-mile course. But Stewart slid off track going into turn 1 on lap 45, giving the lead back to Gordon.
Stewart immediately began to charge back and was back in the top five by lap 66.
Then the drama began to build. On a restart on lap 67, Stewart passed Montoya for fourth in Turn 1 and set his sights on Hamlin and Carl Edwards. Stewart tried to pass both in the Inner Loop, a fast four-turn chicane at the end of the high-speed esses, by cutting through the grass. Hamlin did the same as he fought off the charge and dirt and dust flew.
When Kyle Petty's engine blew seconds later to bring out the sixth caution, Hamlin retained second, with Stewart third and Edwards fourth, followed by Harvick and Montoya.
The contact continued on the ensuing restart. Montoya cut to the inside heading in the first turn, a 90-degree right-hander, blocking Martin Truex Jr., who hit the Colombian rookie's rear end, sending him into Harvick. Harvick and Montoya both spun around, and Montoya was hit hard by Jeff Burton.
Harvick and Montoya got out of their cars and began pushing and shoving before NASCAR officials stepped in. Harvick, who entered the day ninth in the standings, retreated to the pits as his crew worked feverishly to get him back out and salvage as many points as possible.
"We got tapped from behind, and we got run over by the 42," Harvick said. "But it seems the 42 runs over someone every week. I'm frustrated with that particular car. We thought we had a chance to win there."
"I don't appreciate that," Montoya said, referring to Harvick's shoves. "I have no respect for the guy. I used to have respect for the guy."
The race was red-flagged for 26 minutes with 15 laps to go because there was too much debris on the track, and one fan tried to get an autograph from Matt Kenseth by jumping the blue guardrail that lines the course. Kenseth declined because he was a "little busy" and the fan was immediately escorted from the track.
Despite two more cautions, Gordon held off the charges of both Hamlin and Stewart on the restarts and seemed on the road to his fifth win of the season when the race resumed for the final time with eight laps left.
By JOHN KEKIS
AP Sports Writer