KANSAS CITY, Mo. -- With one swing, Alex Gordon turned a miserable night at the plate into a glorious ending.
Gordon stranded six runners in his first three at-bats, including striking out with the bases loaded in the third and grounding into an inning-ending double play in the fifth with runners on the corners.
Gordon, however, made amends by hitting a three-run homer with two outs in bottom of the ninth as the Kansas City Royals rallied for a 7-5 victory over the Baltimore Orioles on Friday night to snap a five-game losing streak.
"At first I kind of knew," Gordon said of it being a homer. "I've been having some bad luck. I was hoping somebody wouldn't jump over the fence and catch it. Even when I hit it, I was kind of like, Please don't catch it. When it went over the fence, it was like a sign of relief. Once it went over, there was definitely excitement.
"I gave a pumped fist, said a couple of bad words and it seemed like I got around the bases to see my teammates smiling at me, so it felt good. I got a couple of punches in the eye [at the home plate mob scene]. Seeing the celebrations before, I just didn't want to get hurt, so I took it pretty easy."
Orioles closer Alfredo Simon (2-2) retired the first two batters in the ninth before walking Rick Ankiel and giving up a single to Wilson Betemit. Gordon's second home run of the season landed in the Royals bullpen.
"I tried to use my split on 3-and-2 to Ankiel," Simon said. "The next guy [Betemit] hit a fastball, and the last guy [Gordon] hit a fastball. My best pitch, my split, wasn't working tonight, so I just tried to throw a strike and he got it."
It was the Royals' first walk-off home run since David DeJesus on July 12, 2008, against Seattle. Gordon said his previous walk-off home run was in 2006 with Double-A Wichita.
"But never in the big leagues," Gordon said. "This is probably one of the highlights of my career so far."
Blake Wood (1-2), who worked the ninth, picked up his first major league victory.
"We needed a win in a bad way," Royals manager Ned Yost said. "We've been struggling to score some runs and our pitching's been struggling to keep us in games. It's just great for Alex to hit the walk-off because earlier he hit into a double play and struck out with the bases loaded. For him to come through there was huge."
Ty Wigginton went 3-for-4 with two RBI doubles for the Orioles, who scored two runs in the top of the eighth to take a 5-4 lead. Nick Markakis led off the Baltimore ninth with a single and scored from first on Wigginton's double to right-center. Wigginton stopped at third on Luke Scott's single.
Adam Jones hit a bouncer to Betemit at third, who fumbled it, allowing Wigginton to score, giving the Orioles a 5-4 lead.
"We've got to win the games we're supposed to win and that was one of those," Orioles interim manager Juan Samuel said. "We got the lead to the closer and we should win that game."
The Royals took a 3-0 lead in the first. Betemit had a two-run single and Ankiel doubled home Jason Kendall.
Jones walked to lead off the Orioles second, stole second and advanced to third on catcher Kendall's throwing error. He scored on Felix Pie's sacrifice fly and Wigginton doubled home Markakis in the third to cut the lead to 3-2.
The Orioles tied it in the sixth, when Markakis led off with a walk, took third on Wigginton's single and scored on Scotts sacrifice fly.
Right-hander Sean O'Sullivan, making his second Royals start since being acquired in a July 22 trade with the Los Angeles Angels, allowed three runs, four hits and two walks in six innings.
Orioles rookie starter Jake Arrieta was pulled after 4 1/3 innings, giving up three runs, six hits and five walks.
IF Josh Bell worked out with the Orioles on Friday, but could not be officially added to the 25-man roster before Saturday. He was optioned July 21 to Triple-A Norfolk and must stay off the big league roster for 10 days. He will take the roster spot of IF Miguel Tejada, who was traded Thursday to San Diego, for minor league pitcher Wynn Pelzer. ... Royals DH Jose Guillen led off the fifth with a double, the 300th of his career.