CHICAGO (AP) — In a matchup of teams on track to both lose 100 or more games, the White Sox avoided getting swept in a three-game series.

Jose Abreu hit a tying home run off Jason Adam in the eighth and pinch-hitter Daniel Palka had a three-run homer off Jason Hammel later in the inning, leading Chicago over the Kansas City Royals 6-4 Thursday.

Kansas City overcame a 2-0 deficit when pinch-hitter Whit Merrifield hit a three-run homer in the eighth off Xavier Cedeno (1-0), but Abreu homered with one out in the bottom half against Adam (0-3). Abreu's 141st big league homer moved him ahead of Ron Kittle into sole possession of 10th on the White Sox career list.

Avisail Garcia doubled, Omar Narvaez was intentionally walked and Hammel relieved. Palka drove a hanging slider a half-dozen rows in the right-centerfield bleachers. He tied the White Sox record of three pinch homers in one season, set by Oscar Gamble in 1977.

"I wanted to hit a home run," Palka said of his mindset.

Rosell Herrera hit a sacrifice fly in the ninth off Luis Avilan, who got his first save in seven major league seasons.

Chicago (38-70) won for the second time in eight games. Kansas City (34-74) had been seeking its first three-game sweep at the White Sox since June 13-15, 2014.

White Sox starter Reynaldo Lopez allowed two runs and five hits in seven-plus innings, leaving with a 2-0 lead after Alcides Escobar doubled leading off the eighth and Adalberto Mondesi reached on a bunt single.

Jace Fry struck out Alex Gordon, Mondesi stole second, and Juan Minaya struck out Salvador Perez. Merrifield greeted Cedeno with his first big league pinch-hit homer.

Lopez had been 0-4 with an 8.27 ERA in his prior four starts.

"I felt good. I felt in command of all my pitches. I was focused today," Lopez said.

Royals rookie Brad Keller gave up two runs, five hits and three walks in 6 1/3 innings.

Narvaez, who has 17 hits in 10 RBIs in his last 12 games, had a run-scoring single in the fourth. Tim Anderson had an RBI double in the seventh off Tim Hill.

"Did a phenomenal job keeping us in the game," Royals manager Ned Yost said.

TRAINER'S ROOM

White Sox: RHP Nate Jones (strained right arm) played catch for the first time in two weeks. ... C Kevan Smith could to begin paternity leave Friday.

UP NEXT

White Sox: RHP Lucas Giolito (7-8, 6.26) is to start Friday at Tampa Bay.

Royals: RHP Heath Fillmyer (0-1, 3.29) is to open Friday at Minnesota.

___

More AP baseball: https://apnews.com/tag/MLBbaseball