OAKLAND, Calif. -- Miguel Tejada forgot how many outs there were in one inning and closer Chris Ray committed a throwing error in the ninth. Both players overcame their miscues to help Baltimore get a tough road win.
After Frank Thomas -- who hit a three-run homer in the sixth -- lined out to left in the eighth, Tejada began jogging off the field. At least six other Orioles joined him, many getting to the foul line before realizing there were just two outs.
"I would say that was a group vapor lock," Orioles manager Sam Perlozzo said. "I just slid my hat down over my face. I've never seen that many people run off the field at once."
Mark Ellis led off the ninth by grounding back to Ray, who promptly threw the ball away at first, allowing Ellis to reach second.
"I was mad for the moment but I realized that run didn't really matter and I wanted to concentrate on the next three hitters," Ray said.
"The offense has been doing a good job all season and it's up to the pitchers to hold down the other team," Loewen said. "We've been doing a better job of that lately."
Thomas hit his 30th homer of the season, but the A's lost for the first time at home since Aug. 8. They've still won 10 of 13 overall and are 25-7 since taking over first place in the AL West on July 29.
"When you have some firepower in the lineup one swing of the bat can get you back in the game," A's manager Ken Macha said. "That's what Frank did. He's been impressive. He's meant a lot to our club. He's probably our MVP."
Loewen (5-4) took a one-hit shutout into the sixth. He wound up allowing two hits and three runs in five-plus innings. He struck out seven and walked four.
"It was difficult to come out of the game when I knew I was letting things get out of hand," Loewen said.
Loewen retired 13 straight after Mark Kotsay singled with one out in the first.
Dan Haren (12-11) lost his second straight start after winning his previous six. He matched his season low with five innings, allowing five runs and six hits. He struck out three and walked one.
"The early innings have given me trouble," Haren said. "I don't know if it's a focus thing, or something physical or mental. I'm going to take a look at it."
The Orioles took a 2-0 lead in the first. Roberts reached base safely on Marco Scutaro's fielding error and scored when Gomez doubled. Tejada singled home Gomez.
Gomez and Tejada also drove in runs in the third, and Markakis hit an RBI double in the fifth to make it 5-0.
"I just try to do my work in batting practice and in the cage," Gomez said. "The mental part is the biggest thing and you just want to be prepared. It's nice to get a game against a good team."
Loewen walked Kendall and Swisher to open the sixth and gave up a broken-bat RBI single to Milton Bradley. Julio Manon came in to face Thomas, who drilled a 3-2 pitch halfway up the staircase beyond the left-field fence to get the A's within 5-4.
Thomas reached 30 home runs for the ninth time in his career and the first since hitting 47 in 2003.
The Orioles added a run in the seventh. Scott Sauerbeck hit Danny Ardoin to lead off the inning. After Jeff Fiorentino sacrificed Ardoin to second, Roberts tripled off the glove of Jay Payton, who appeared to lose sight of the drive.
- Plate umpire Marvin Hudson left the game after three innings when he sustained a blow to the head on a backswing by A's SS Marco Scutaro.
- A's 3B Eric Chavez missed his second game with a moderate sprain on the inside of his right ankle.
- Orioles C Ramon Hernandez missed his third game with a strained ribcage.
- Gomez doubled twice in the same game for the first time since Aug. 16, 2002, against the Kansas City Royals.
- Kotsay left the game after three innings with tightness in his back.
- Haren is now 6-2 in nine starts against the AL East.