SEATTLE -- Seattle manager Mike Hargrove's second big decision in the late innings easily made up for one that failed.
Hansen worked a full-count against Tampa Bay closer Danys Baez (4-1), and hit a fastball into center field that scored Richie Sexson and Raul Ibanez. Center fielder Alex Sanchez misplayed the ball and Bret Boone scored from first with the winning run.
It was Seattle's second win this season when trailing after the seventh inning.
"It is a game of percentages. Sometimes it works and sometimes it doesn't," Hargrove said. "That was as good an at-bat as we've had all year."
The move that failed came in the seventh, when Hargrove brought in left-handed reliever Ron Villone to face lefties Sanchez and Carl Crawford and Seattle holding a 2-1 lead.
Sanchez hit a two-run double on Villone's first pitch and Crawford hit the next pitch for a two-run single, giving Tampa Bay a 5-2 lead.
Seattle scored a run in the seventh as Willie Bloomquist scored on Ichiro Suzuki's sacrifice fly.
In the eighth, Sexson walked with one out, followed by an infield single from Ibanez. Boone walked to load the bases, and after Jeremy Reed struck out, Hansen singled. It was Hansen's first hit as a pinch-hitter this year. He started the season fifth all-time in pinch-hits.
"My mind-set was really to zone him up to a pitch I could handle," Hansen said. "I wasn't thinking of putting it in the gap or anything; I was just trying to hit it back up the middle. Usually that doesn't happen, but tonight it went right up the middle."
Julio Mateo (2-1) pitched the eighth for Seattle, and Eddie Guardado worked the ninth for his 150th career save and 16th this season. He is tied for the American League lead in saves and has not given up a run in his last 10 innings pitched.
Baez blew his fifth save of the season.
"Quite frankly, I'm getting tired of losing the same way," Tampa Bay manager Lou Piniella said. "It's something we've been in all year and I hope we get out of it soon, because it's hard to win games when you put people on base instead of making the other team earn it."
The Devil Rays were trying for consecutive road wins for the first time this season and the first time since beating Kansas City on Sept. 11-12 last year.
The loss ended a six-game winning streak for Tampa Bay at Safeco Field.
Villone took over for starter Joel Pineiro with one out in the seventh. Pineiro had loaded the bases after hitting Jorge Cantu with a pitch, allowing a single to Travis Lee and issuing an intentional walk to Toby Hall.
Sanchez drove Villone's pitch into the gap in right-center field scoring Cantu and Lee. Crawford hit the next pitch into center field, scoring Hall and Sanchez.
Crawford and Sanchez each had two hits for the Devil Rays.
Tampa Bay starter Scott Kazmir had his fourth straight solid start, allowing three runs and three hits in 6 1/3 innings of work. The left-hander has allowed three runs or less in each of his last four starts and is 2-0 in his last five.
Kazmir's only mistake came in the fourth when Ibanez hit his seventh homer of the season, a two-run shot to right-center. Seattle's only other hits off Kazmir came from Randy Winn and Rene Rivera.
"It's frustrating for us. We played a good game out there and a couple of things just didn't go our way," Kazmir said.
Tampa Bay scored its first run in the third. Green walked to lead off and scored on Crawford's two-out single past a diving Boone at second base.
Otherwise, Pineiro was solid until the seventh. The right-hander struck out a season-high seven and appeared on the verge of his first win since April 26 at Texas. He allowed only two batters to reach second in the first six innings.
Tampa Bay had knocked around Pineiro for a season-high seven runs on 10 hits last Sunday.
"That was the best I felt all year, arm wise and pitches wise," Pineiro said. "Everything was there."
Ibanez continued a recent surge with his two hits. In his last six games, Ibanez is 13-for-23, raising his average from .270 to .305, and has hit safely in 19 of the last 21 games.