TORONTO (AP) -- Baltimore catcher Ramon Hernandez knows his team can't afford to watch four-run leads turn into one-run losses.
Alex Rios scored when Freddie Bynum misplayed a grounder at shortstop in the bottom of the ninth and the Toronto Blue Jays scored five times in the final three innings to beat the Orioles 7-6 on Tuesday night.
"These are the kind of games you can't lose," Hernandez said. "It's really hard to lose a game when you're winning going into the seventh by four or five runs."
It was Toronto's first walk-off victory since a 2-1 win over the New York Yankees last Sept. 13.
"We needed a game like that, a come-from-behind game, as far as getting the club rolling," Blue Jays manager Cito Gaston said. "Hopefully it will give us a boost."
"It was a breaking ball down," Hernandez said. "I tried to throw as quick as I could. Rios runs pretty good. I ended up trying to be too quick and throwing it away."
Orioles manager Dave Trembley said there was no excuse for his team's late-game gaffes.
"It doesn't take a rocket scientist to figure it out," Trembley said. "If you're going to give them five outs late in the ball game, they're going to score a run and they're going to be beat you."
A testy Bynum was in no mood to discuss the play afterward.
"If you watched the game you know what happened, so what do you want to talk about?" he snapped.
Blue Jays starter Dustin McGowan left after four innings with a sore right shoulder and will have an MRI Wednesday. He allowed four runs, though only two were earned, on four hits.
"It's been tender, but tonight it really started barking on me," McGowan said. "It just went a little overboard."
B.J. Ryan (2-3) worked a perfect ninth after the Blue Jays came back from a 6-2 deficit.
"This is a huge one," Toronto's Vernon Wells said. "We need a bunch more like this in order to get back in this thing."
Orioles right-hander Daniel Cabrera left in the seventh after two of the first three batters reached safely. Dennis Sarfate came on and got Joe Inglett to fly out, but loaded the bases with a walk before Alex Rios hit a three-run triple and Wells followed with a game-tying single.
"They showed a lot of patience," Trembley said. "Sarfate was getting behind, they fouled off some pitches. They made him come across the plate, they didn't chase pitches out of the strike zone."
Cabrera allowed four runs, six hits and four walks in 6 1/3 innings.
"He worked way too hard tonight," Trembley said. "He just didn't seem to get in any kind of rhythm early."
Aubrey Huff's solo shot in the first was his 18th of the year, but Toronto tied it in the bottom half on Wells' RBI single.
Baltimore scored two unearned runs in the third when Rolen couldn't come up with Adam Jones' leadoff grounder to third. Jones took third on Fahey's sacrifice and scored on a wild pitch before Brian Roberts walked, stole second, went to third on an infield single by Nick Markakis and scored on Huff's sacrifice fly.
Baltimore made it 4-1 in the fourth on Jones' double, but Toronto got one back in the bottom of the inning when Rod Barajas hit an RBI single.
Markakis made it 6-2 in the seventh with a two-run single off left-hander Scott Downs.
Rolen's error was just his fourth of the season. ... Baltimore placed LHP Adam Loewen (left elbow) on the 15-day DL and purchased the contract of LHP Alberto Castillo from Triple-A Norfolk. Loewen will consult with doctors before deciding whether to undergo surgery for the second time in the past two years. ... Toronto Maple Leafs coach Ron Wilson attended the game.