EDMONTON - It took a last-gasp touchdown to give Edmonton Eskimos a win in a classic back-and-forth matchup with their bitter provincial rivals.

Ricky Ray wouldn't have it any other way. Ray hit Fred Stamps with a 23-yard pass with just nine seconds to play as the Eskimos took sole possession of first place in the CFL's West Division, defeating the rival Calgary Stampeders 38-35 in a thriller on Thursday.

"That was a ton of fun," said Ray. "In the CFL you get to play in a lot of games like this, especially against a guy like (Calgary quarterback Henry) Burris, who has done this to us. It's great to come out on the winning end of a shoot-out like that. It's a great uplift for the team. It's a huge win for us."

Down by four late in the fourth, Edmonton took its first lead of the game at 31-28 with just 3:35 to play as Maurice Mann scored on an 11-yard TD pass shortly after a massive 71-yard punt return from Tristan Jackson.

Calgary quickly responded and looked to have the game won with 38 seconds left as Jeremaine Copeland struck for his second touchdown of the game on an 11-yard toss.

But Jackson gave the Eskimos tremendous field position again with a 35-yard return, leading to a clutch diving catch by Stamps in the dying seconds for the receiver's second touchdown of the game.

Going into a bye week, Eskimos head coach Richie Hall said he couldn't have asked for a better result.

"Regardless of what happens, we are coming back in first place," he said. "Now we have one up on Calgary. It's going to be a dogfight for all the teams in the West and any chance you get to win, especially a win like this, it's a real bonus. It's great for our confidence."

It was the third win in the last four games for the Eskimos (4-3).

Calgary (3-4) has lost two of its last three.

Burris said the loss was eerily familiar to a game between the two teams last year when Jason Tucker reeled in a 36-yard pass in the final minute to give Edmonton a 34-31 win.

"They got us last year in this situation and of course you didn't think it was going to happen again or even could happen again," he said. "It felt so great to get that late touchdown and with 38 seconds on the clock nobody was even thinking about last year. We had to stop Jackson and we didn't. And we had to stop Ray and we didn't. Kudos to Edmonton."

Throwing for 269 yards in the first half alone and an impressive 479 in the game, Burris eclipsed Doug Flutie's club record of 20,551 career passing yards.

The Stampeders took the lead just five minutes in, confidently driving the ball downfield before Burris hit Teyo Johnson with a dump pass for a 10-yard touchdown and an early 7-0 lead.

The Eskimos tied the game with just over a minute remaining in the opening quarter as Ray found Stamps open on a deep route for a 49-yard passing touchdown - the first time this season Edmonton has scored a touchdown in the first quarter at home.

It only took the Stampeders a minute and a half into the second quarter to respond as they put together another solid drive, culminating in a 14-7 Calgary lead. The Stampeders capped the drive with a 12-yard Jon Cornish TD on a lateral from Burris.

Edmonton came back with an impressive march to even the score midway through the second as Calvin McCarty finished things off by bulldozing six yards into the end zone.

Calgary went up 21-14 with three minutes left in the half as Jeremaine Copeland reeled in a huge 46-yard pass to the Edmonton 11 and then took a subsequent pass in for the TD.

But Edmonton tied the score again with just 1:01 to play in the half as Ray got himself out of some trouble and sprinted 27 yards for the touchdown.

"I didn't have anything downfield so I just took off," Ray said. "Man, I was tired after that run."

Sandro DeAngelis missed a 30-yard field goal attempt on the final play of the half but it went through for a single to make it 22-21 Calgary at halftime.

The Eskimos were threatening early in the third but Arkee Whitlock coughed up the ball deep in Calgary territory at the six-yard line. Dwight Anderson snapped it up for the Stampeders and took it all the way back to the Edmonton 52, eventually leading to a 20-yard field goal by DeAngelis.

Edmonton was stopped on a third down gamble at the Calgary 34 and the Stampeders turned that into another DeAngelis field goal and a 28-21 lead through three quarters.

The Eskimos finally put some second half points on the board six minutes into the fourth as Noel Prefontaine hit for a 25-yard field goal to cut the Calgary lead to four points, setting up the late-game fireworks.

The two teams combined for a startling 1,054 yards in total offence and 432 return yards in the game.

Both teams have a bye next week. Calgary returns to action on Aug. 28 in Toronto while the Eskimos will next play on Aug. 29 when they host Hamilton. The two Alberta-based clubs will then face each other twice more in the Labour Day game in Calgary followed by a rematch in Edmonton.

Notes: Edmonton came into the game in serious need of a few turnovers in their direction. In their first six games they recorded only one fumble recovery and zero interceptions. By contrast Calgary had 11 fumble recoveries and eight interceptions. The Eskimos had also coughed up the ball 17 times themselves. ... The Eskimos were missing defenders Maurice Lloyd (hamstring) and Lenny Williams (leg) but saw the return of receiver Mann. ... Earlier in the day Mann and kick returner Tristan Jackson signed contract extensions that will see them remain with the Esks through to the end of the 2011 season. ... Edmonton running back Jesse Lumsden underwent successful shoulder surgery on Tuesday, ending hopes of a return this season. Lumsden was injured in the first game of the season.