OAKLAND, Calif. (AP) -- Ramon Hernandez began the day feeling woozy, and he ended it by driving in the winning run on a weak grounder.
"I had headaches and wanted to go to sleep," said Hernandez, who entered the game as a defensive replacement in the top of the ninth. "The next thing I know, the winning run was on third. It can't get any better."
After Terrence Long flew out, Ellis hit a fly off Hector Carrasco (0-2) that bounced in and out of Melvin Mora's glove as he hit the left-field fence for a triple. Billy McMillon then was walked intentionally to set up a potential double play.
With runners on first and third and a drawn-in infield, Hernandez tapped a grounder to Carrasco, who turned and threw to second without looking at Ellis, coming down the third-base line, ending a well-pitched game by both starters.
"I was just kind of surprised," Carrasco said. "As soon as the guy makes contact, the guy from third comes charging home right away. Even if I threw it, I have no chance."
With the infield in, Hernandez was looking to drive something up the middle.
"It's a lot more open there with them playing in, but he made a good pitch on my hands," Hernandez said. "I think he just forgot the infield was in. This game is amazing because you never know when stuff like that will happen. You hit the ball back to the pitcher and drive in the winning run."
With the A's winning their fifth in a row, manager Ken Macha will receive a buzz cut from Tim Hudson when the team resumes play in Minnesota on Thursday.
A's starter Barry Zito, one of three Oakland pitchers selected for the All-Star Game, allowed four hits over eight innings with two walks and two strikeouts.
Baltimore's Jason Johnson pitched five-hit ball over 7 2/3 innings. He walked one and struck out seven.
All-Star Keith Foulke (7-1) retired all three batters he faced.
"It's a shame for a game to end on a note like that," said Orioles manager Mike Hargrove. "It was so well played by everybody. It's one of those situations where you'll analyze it later."
Zito retired the first 12 batters he faced. He walked Jeff Conine to lead off the fifth and allowed his first hit two outs later when David Segui blooped a single just beyond the grasp of Ellis in shallow right field.
It was a turnaround from Zito's last start, when he allowed a career-high 15 hits against the Tampa Bay Devil Rays on Tuesday. He has given up 35 in his last three starts combined.
"I pitched like the way I knew how," Zito said. "Before, I was trying to be too fine, too nitpicky instead of throwing it in there and letting them hit it."
Conine and Fordyce were the only Orioles to advance past first base through seven innings.
Johnson was just as effective, taking a four-hitter into the eighth. He had given up a season-high 10 hits in his last start in Seattle on Tuesday and had allowed 18 in his previous two starts.
Eric Chavez led off the second with a double but was thrown out when Roberts threw to third on Long's infield grounder. McMillon's single with two outs sent Long to third, but Adam Melhuse struck out.
The A's also had runners on first and third with one out in the fourth, but Ellis struck out and McMillon grounded out to first.
After Long reached on Roberts' fielding error in the fourth, Johnson set down the next 11 batters he faced.
The A's swept a three-game series from Baltimore for the first time since Sept. 3-5, 2001. ... The Orioles announced RHP Rodrigo Lopez would start Thursday's game against Anaheim, followed by RHP Rick Helling, RHP Sidney Ponson, Johnson and RHP Pat Hentgen. ... The 54 wins at the break was the most since the A's won 54 in 1988.