Doug Fister (8-5) picked up the victory with six strong innings, yielding a run, while allowing six hits and striking out five and walking one.
Cabrera, who is second in the league with 31 home runs to Chris Davis of the Baltimore Orioles, drove a 1-1 pitch out to left in the first inning.
Miguel Tejada tied it in the second with his third home run of the season and the 307th of his career. Tejada took an 0-1 Fister pitch out to left.
Dirks broke the tie with a home run with one out in the fifth to straightaway centre, just eluding Jarrod Dyson's leap at the wall.
James Shields (4-7), who has won only one of 10 home starts, took the loss.