DETROIT -- Rajai Davis hit a walk-off grand slam with one out in the ninth inning Monday night to give the Detroit Tigers a 5-4 victory over the Oakland Athletics.

The Tigers won the opener of a three-game series between division leaders that met in each of the last two postseasons.

Third baseman Nick Castellanos singled to third off lefty Sean Doolittle (1-3) to open the ninth, and catcher Alex Avila lined a single past second. With one out, Center fielder Austin Jackson drew only the second walk issued by Doolittle this season.

Davis then hit a 1-0 pitch for his third career grand slam and first career walk-off home run.

Rookie lefty Blaine Hardy (1-0) got his first major league win after throwing a 1-2-3 ninth for Detroit.

Oakland scored three times in the eighth to take a 3-1 lead. Left fielder Yoenis Cespedes was safe at first when Tigers shortstop Eugenio Suarez threw the ball over first baseman Miguel Cabrera's head on an easy ground ball to open the inning. Right fielder Brandon Moss then slammed an RBI double to deep left center on a 2-2 pitch from right-hander Anibal Sanchez, breaking a 1-1 deadlock.

Right-hander Joba Chamberlain relieved Sanchez and allowed a walk and a single before shortstop Jed Lowrie lined a two-run single to left.

Cabrera rocketed a hanging 2-2 curveball from A's starter Scott Kazmir into the seats in left-center to square the score at 1-1 in the sixth.

With two outs in the sixth, Lowrie blooped an RBI single to center, scoring Cespedes from third to break a scoreless tie.

Sanchez allowed three runs (two earned) in seven innings. Kazmir limited Detroit to one run in 5 1/3 innings.

Oakland put the leadoff man on in each of the first three innings but could not get him home. The A's got the second batter on in the fourth, and they went down in order in the fifth.

Detroit got a two-out double by first baseman Miguel Cabrera in the first inning, a two-out single by second baseman Ian Kinsler in the third, and a two-out single by left field Rajai Davis in the fifth. None resulted in a run, however.

NOTES: Detroit DH Victor Martinez was a late lineup scratch due to soreness in his lower back/side area. He was replaced by J.D. Martinez, originally scheduled to get the game off. J.D. Martinez went 0-for-2 with two walks. ... Oakland made a position switch before the game, shifting Brandon Moss from first to right field and moving Stephen Vogt from right to first base. ... The A's hit the midpoint of their schedule with a 51-30 record, third best in Oakland history. The 1971 team was 53-28, and the 1988 squad 52-29 halfway through the season. ... Detroit LHP Ian Krol threw his second bullpen session Monday without incident and could be headed for a brief rehab assignment soon. He was placed on the disabled list June 21 with a sore left shoulder.