LONG POND, Pa. (AP) -- Jeff Gordon had the inside line, a lead and his first win of the season in sight, usually a sure thing for Pocono's top winner.

Kasey Kahne was about out of time to pass his Hendrick Motorsports teammate.

''It was either to go for it and make it work,'' Kahne said. ''Or not.''

Cruising from the outside, Kahne got the jump he needed, zipped past Gordon and pulled away with two laps left Sunday to win at Pocono Raceway.

''I about gave it away when Jeff got by me,'' Kahne said.

Kahne recovered in the No. 5 Chevrolet for his second victory of the season, all but securing his spot in the Chase for the Sprint Cup championship. He had the car to beat for the final half of the 400-mile race until a late caution bunched up the field.

Gordon nudged past Kahne after some thrilling two-wide racing and seemed poised to win at Pocono for the seventh time. After the final caution, Kahne was simply too fast, too strong to be denied his first win at Pocono since 2008.

So close to the checkered, this loss stung Gordon. Even worse, his runner-up finish came on his 42nd birthday in his 42nd career Pocono start.

''I thought all I needed to do was get in here and got to the bottom and I'd be good,'' Gordon said. ''He got a killer run and blasted by on the outside of me. Caught me by surprise. It just kills your momentum.''

Kurt Busch, who also celebrated a birthday, Ryan Newman and Dale Earnhardt Jr. rounded out the top five. The top five cars were Chevrolets.

Busch helped out Kahne with one final push down the frontstretch to find some needed speed.

''That was kind of the race at that point,'' Kahne said. ''Once I cleared (Gordon) getting into two, from there it was just, don't make a mistake and try to run the quick lap on the last one.''

Kahne, Gordon and Earnhardt made it an outstanding race for Hendrick. Teammate and series points leader Jimmie Johnson was 13th after a blown tire knocked him out of the lead.

Kahne had stretched his lead to almost 8 seconds when a caution for debris came out with 12 laps left. Gordon, who won at Pocono each of the last two years, was strong in the No. 24 and had the lead as he tried to extend his record for career wins at Pocono.

Matt Kenseth spun with four laps left to erase Gordon's lead and set up the thrilling finish. Gordon led again until Kahne ran him down with a hard, sweeping run past his teammate for the win.

''We had them. We certainly had the position,'' Gordon said. ''I'm pretty disappointed I let him get inside of me on (turn) one.''

Kahne also won this season at Bristol. He jumped a spot to eighth in the points standings and need a win to make sure he'd at least qualify for a wild-card spot should he fall below 10th place. Kahne was third last week at Indianapolis Motor Speedway and seems to be heating up with five races left until the Chase field is set. With two wins, he'd also be closer to Johnson and Kenseth once the points are reset when Chase field is set.

Kahne's 16th career win should make him a Chase lock.

''The Chase is what it's all about in NASCAR,'' Kahne said. ''You need to make it.''

Gordon, who has six Pocono wins, finished second last week and has three straight top 10s to also position himself for a spot in the 12-driver field. He had won at Pocono each of the last two seasons. When Gordon leads late at Pocono, he usually wins. Just not this time.

''I'm frustrated right now because we had a shot at it,'' Gordon said. ''We know how important wins are.''

Gordon hangs on to ninth in the standings, but could be out of a Chase spot if he falls outside the top 10 without a win.

Johnson, who set a track record in qualifying, again had the dominant car for half the race until he blew a front tire. A week after a slow, final pit stop cost him a win at Indianapolis, Johnson was done in this time by a tire issue that ended his chance to win.

Johnson, who won the June race from the pole, stretched his points lead to 77 over Clint Bowyer.

Danica Patrick lost control of her car, triggered a four-car crash and was 35th. Kenseth's late spin knocked him to 22nd.

But it was that spin that made the difference for Kahne. He may not have caught Gordon without the final caution.

''We had speed. I could move around,'' Kahne said. ''But to actually clear him and make the pass, I think it would have been really difficult. I'm glad that second caution came out there and gave us another shot.''

Kahne took a moment in Victory Lane to remember his friend, Jason Leffler. Leffler was killed in June on a dirt track in New Jersey only days after racing in the Pocono Cup race.

Kahne and Leffler were friends and traveled together on the way home from the June race.

''Just me and him,'' Kahne said. ''We spent a bunch of time together and then that happened that Wednesday. It was tough. There are so many people that are good friends with Jason and knew him really well. I just wanted to mention something about him.''

Online Public Information File

Viewers with disabilities can get assistance accessing this station's FCC Public Inspection File by contacting the station with the information listed below. Questions or concerns relating to the accessibility of the FCC's online public file system should be directed to the FCC at 888-225-5322, 888-835-5322 (TTY), or fccinfo@fcc.gov.