Perhaps the most impressive accomplishment by the Baltimore Orioles this season is signing shortstop J.J. Hardy to a three-year extension.

Hardy has been one of the few standout performers for the last-place Orioles, and he showed his value again Friday night, hitting two home runs in a 5-4 loss to the Detroit Tigers.

It was Hardy's third multihomer game of the season, and it gave him 23 for the season. He drove in three runs and now has 58 for the year, third on the team behind Adam Jones and Mark Reynolds.

His numbers might be even higher had he not spent a month on the disabled list with an oblique injury.

"He's played a (heck) of a shortstop," Jones said. "He's been consistent since he's been here. Aside from the 15 or 20 days he missed earlier in the year, he's been unbelievable."

Obtained during the offseason in a trade with Minnesota, Hardy became an immediate hit with Baltimore. So last month, the Orioles gave him a new contract that guarantees him $22.25 million over three additional seasons through 2014.

It appears like it's going to be a worthwhile investment.

Hardy's two-run homer in the first inning gave Baltimore a short-lived lead, and his solo shot in the fifth helped the Orioles climb into a tie. He also made two brilliant plays in the field, but it wasn't enough to prevent Baltimore from absorbing its eighth loss in 10 games.

"I think we battled," Hardy said. "They just came out on top."

Wilson Betemit homered and rookie Andy Dirks had a career-high four hits for the Tigers, who maintained their three-game lead over second-place Cleveland in the AL Central.

Detroit went up 5-4 in the sixth. Austin Jackson hit a leadoff double off Troy Patton (0-1) and Dirks followed with an RBI single.

Jackson helped preserve the lead with a leaping catch at the top of the center-field wall on a drive by Jones.

"I've done it before to people," Jones said, "so I know the feeling."

Brad Penny (8-9) allowed four runs and seven hits in 5 1-3 innings to snap a personal three-game losing streak.

Jose Valverde, the last of three Detroit relievers, worked the ninth for his 34th save in 34 tries.

Orioles starter Alfredo Simon gave up four runs, 11 hits and three walks in 4 2-3 innings. He has yielded 21 hits in his last two outings.

"My starts can be better than that," the right-hander said. "I know I can do better than that. Sometime I get into trouble in the first and second inning, so I got to face that and just do better."

Betemit's fifth homer of the season, after Alex Avila led off the fourth with a single, put Detroit ahead 4-2. The Tigers could have had more, but right fielder Nick Markakis threw out Jackson trying to score on a fly ball and first baseman Chris Davis made a diving snag of a two-out grounder by Victor Martinez with two runners on.

Hardy hit his second homer of the game in the fifth, Jones doubled and Vladimir Guerrero broke a 1-for-24 slump with an RBI single to tie it at 4.

That, however, would be Baltimore's final run.

Miguel Cabrera put Detroit up 1-0 in the first with an RBI single, but Simon got Jhonny Peralta to hit into an inning-ended double play with the bases loaded.

Orioles manager Buck Showalter shook up the lineup in an effort to get more production from an offense held under four runs in seven of its previous 11 games. Nolan Reimold batted leadoff and Guerrero was dropped a notch from the cleanup spot for the first time this season. Reimold became the sixth different player to bat atop the order, including Brian Roberts, who hasn't played since May 16 because of a concussion.

Showalter's hunch was promptly rewarded. Reimold drew a first-inning walk and Hardy followed with a drive to left for a 2-1 lead.

A sacrifice fly by Jackson tied it in the second.

NOTES: Tigers reliever Al Alburquerque received a concussion when struck by a ball during batting practice. He was placed on the 7-day concussion DL after the game. ... Magglio Ordonez snapped an 0-for-14 skid with a first-inning single, and in the bottom half Reynolds singled to end his 0-for-17 slide. ... Detroit will send Max Scherzer (11-7) to the mound Saturday night against the Orioles, who will counter with Jeremy Guthrie (5-15). Scherzer is one win short of matching his career high, and Guthrie is 3-1 with a 2.62 ERA in five lifetime starts against the Tigers. ... Orioles RHP Jake Arrieta had successful surgery Friday to remove a bone spur from his right elbow.