Kansas City starter Edison Volquez (10-10) pitched five innings and allowed two runs, both unearned, and three hits.
The Royals' bullpen, which has been a successful formula for the reigning two-time AL pennant winners, pitched four scoreless innings to push their franchise-record scoreless streak to 38 2/3 innings -- the best in the majors since 2002-03 when San Francisco tossed 39 1/3 straight.
Kelvin Herrera pitched a flawless ninth for his ninth save in 11 chances.
Tom Koehler (9-9) allowed four runs, three earned, and seven hits in six innings for the Marlins.
Kansas City went 4 for 28 with runners in scoring position and scored six runs during the three-game series, but left Miami with two victories.
The Marlins also struggled hitting with runners in scoring position during the series going 3 for 26 and leaving 24 men on base including 11 on Thursday.
The Royals opened the scoring in the third on an RBI double by Perez after the Marlins elected to intentionally walk Eric Hosmer with first base open. Cheslor Cuthbert scored on Perez's ground ball down the left-field line.
Escobar extended the Royals' lead to 2-0 on a home run to center field in the fourth. It was his third of the season and second of the month.
Cuthbert had two doubles to go with two errors, one of which led to the Marlins' two runs coming in the fourth to tie the game at 2.
Escobar's tiebreaking RBI double off Koehler in the sixth gave the Royals the lead. Morales' pinch-hit sacrifice fly put the Royals on top 4-2.
The Royals pushed their lead to 5-2 in the ninth as Raul Mondesi walked, stole two bases, and scored on catcher J.T. Realmuto's throwing error trying to get Mondesi at third on his stolen base attempt.
Both teams combined for six errors.
DYSON WEB GEM
Dyson ran to make a leaping left-handed grab up against the wall in center field. Many of Dyson's teammates gave him the Royals' customary tip of the cap for an impressive defensive play on his way back to the dugout.
Marlins: RF Giancarlo Stanton (groin strain) is hopeful he can return to the team at some point during the regular season to help the Marlins' after sustaining the injury on Aug. 13. "Anything could help so whatever I can do to be back, if it's possible, is going to happen," Stanton said.
Royals: RHP Ian Kennedy (8-9, 3.58) will start Friday's game at Boston against RHP Steven Wright (13-5, 3.01) in a three-game series with the Red Sox. Kennedy has recorded five straight starts of at least six innings and one-or-fewer runs matching Larry Gura for the longest such streak in franchise history. Kennedy is 2-0 with a 0.79 ERA during the stretch.
Marlins: RHP David Phelps (7-6, 2.28) will take the mound Friday to begin a three-game series against San Diego, which will start former Marlins RHP Jarred Cosart (0-1, 4.54). Phelps is 2-1 with a 1.31 ERA over his last four starts since moving into the rotation.