With the game tied 2-2 in the eighth, Royals reliever Aaron Crow (2-2) hit Miguel Cabrera with a pitch to start the inning.
The MLB batting and RBI leader went to third when Prince Fielder followed with a single and then scored the decisive run on a fly ball by Martinez.
Max Scherzer (9-0) ran his unbeaten streak to 13 starts beginning the season, yielding a pair of runs on just three hits over seven innings. He walked two and fanned six, raising his season's strikeout total to 106 over 90 1/3 innings.
David Lough clouted a solo homer for the Royals.
Caroline Berg Eriksen: Soccer player's wife triggers debate with post-birth selfie
Texas principal bans speaking Spanish, stirs controversy