KANSAS CITY, Mo. — The temper inside the home clubhouse at Kauffman Stadium was bolstered not simply by a winning streak but the manner in which the Royals had built it. There were unlikely culprits, the reminiscent avenues of offensive production and the late drama. The recipe produced the longest home winning streak in more than two seasons.

It took 12 innings to put it to rest.

The White Sox halted the Royals’ home surge with a 4-2 win at Kauffman Stadium.

Kansas City (49-96) had won seven consecutive games inside its own ballpark. White Sox shortstop Tim Anderson supplied the game-winning two-run blast with two outs in the 12th.

That multiplied the affliction of one half-inning earlier, when the Royals placed runners at second and third with one out but failed to score. Vying for the Royals second walk-off win of the three-game series, Rosell Herrera lined out to shortstop, and pinch-runner Brett Phillips broke for home. The White Sox doubled him off.

The Royals got a four-hit night from shortstop Adalberto Mondesi. On Tuesday, Mondesi impacted the game with his legs. On Wednesday, it was his bat, too.

Hitting from the right-side against lefty starter Carlos Rodon, Mondesi pounded hits in his first four plate appearances, tying a career-high. His second and third hits — both with two outs — drove in the only two runs. His fourth was an infield hit after he beat out a ground ball to the pitcher, shocking White Sox lefty Aaron Bummer, who had casually lobbed the ball to first base.

That hit loaded the bases, but Alex Gordon grounded out to end the threat, returning the favor after the White Sox had left them loaded in a tie game in the top half of the seventh.

The Royals transitioned to a six-man rotation, accommodating room for left-hander Eric Skoglund. In his first turn since May, Skoglund made only one mistake. But it burned him for a deficit.

After weaving through three innings, Skoglund left a curveball over the upper echelon of the strike zone, and Jose Rondon punished him for a 369-foot home run. The two-out, full-count blast gave the White Sox a 2-1 lead in the fourth.

Skoglund was precise otherwise. He threw five innings, allowing only two hits. He finished three pitches shy of his projected 70-pitch count limit. The Royals helped him out in the third, second baseman Whit Merrifield firing home to gun down Adam Engel at the plate.

Rodon, the ace of the White Sox staff, fought command issues for his six innings, walking five. But he limited the consequences to two runs.

Merrifield stole two bases off Rodon — one in the third and one more in the fifth — and promptly scored after each of them. He could have — and should have — had company on his path to the plate in the fifth, but Ryan O’Hearn was caught scurrying back to third base after a wide turn on Merrifield’s double. O’Hearn had received a late stop sign and could not retreat before the White Sox threw behind him for the second out. Mondesi followed with a single that scored just one instead of two.

Merrifield leads the American League with 35 stolen bases, and he paces all of baseball with 13 swipes of third base. He had 34 in 2017, tops in the league. Mondesi and Alex Gordon also successfully stole bases, giving the Royals four of them for a second consecutive night.