"It was a great game back and forth, a lot of clutch hits by both teams," said Alex Gordon, who homered in both games. "It was good to see and hopefully we can build on this."
Rookie Kolten Wong's first career home run was a grand slam in the second that ended the Cardinals' 20-inning scoreless drought and gave them an early four-run cushion. Wong said it was the first grand slam he's hit at any level.
"It's awesome," Wong said. "It was good to get us up early, try and give us a chance."
The Cardinals finished a dismal 2-7 home stand when their pitchers faltered and fell to 30-29 overall. Before the game, manager Mike Matheny fielded an endless series of questions about the lack of hitting.
Gordon's three-run homer capped a six-run fifth for the Royals against Jaime Garcia that put them up by two.
"We can't complain about what the offense did," Matheny said. "It just wasn't enough."
Kansas City starter James Shields also scuffled, surrendering five earned runs in 5 1/3 innings, and has given up seven homers his last three starts. Shields helped himself with two hits, including an RBI double.
"I was just kind of all over the place, really wasn't commanding my slider at all," Shields said. "I made three crucial bad pitches and that's what caused six runs."
Peter Bourjos' 422-foot homer put the Cardinals ahead 7-6 in the sixth. Alcides Escobar's bloop RBI single off Pat Neshek tied it in the eighth, a rally fueled by pinch hitter Billy Butler's infield hit.
Omar Infante doubled off Rosenthal (0-3) with one out in the ninth ahead of Hosmer's hit.
Wade Davis (5-1) allowed a hit in the eighth and Greg Holland worked the ninth for his 16th save in 17 chances for the Royals, the home team for the last two games of intrastate interleague series that resumes Wednesday.
"That was one of those grinder games, where you're grinding right from the get-go -- everybody," Royals manager Ned Yost said. "It was a great game."
Jhonny Peralta added two doubles and an RBI for St. Louis, outscored 14-0 the previous two games by the Royals and Giants.
Wong was chosen as the NL rookie of the month earlier Tuesday and his slam in the second was the Cardinals' fifth hit in 10 at-bats against Shields.
St. Louis loaded the bases in the first, too, but Yadier Molina grounded into an inning-ending double play on good glovework by Escobar at shortstop and capped by Infante's barehanded grab on the move at second and relay.
The Royals had one runner in scoring position the first four innings, then batted around and hit for the cycle in the sixth to take the lead. Gordon homered for the second straight day, Escobar had an RBI triple and Shields had an RBI double with his second straight hit.
No St. Louis relievers warmed up during the rally and Matheny said after the game a couple of pitchers had been unavailable.
"I'm on the mound, I'm trying to execute pitches until the manager takes the ball out of my hand," Garcia said. "I'm not looking anywhere else."
Cardinals RHP Adam Wainwright (8-3, 2.32) opposes Jason Vargas (5-2, 3.39) on Wednesday night. Wainwright is 4-1 against the Royals and 9-5 overall in interleague play. Vargas has at least six strikeouts his last five starts, the longest such stretch of his career. ... Shields is the first Royals pitcher to get an RBI since Luis Mendoza May 29, 2013, at St. Louis. ... The Royals' six-run inning tied their season best and tied the best against the Cardinals. ... Matt Holliday walked twice and has reached safely the first 30 home games. ... The Royals have played six games with new batting coach Dale Sveum, and have scored six or more runs in four of them. ... Escobar's hit ended Neshek's career-best streak of 20 2/3 scoreless innings. ... Wong, the Cardinals 2B, said he jammed his shoulder a bit diving for Butler's infield hit in the eighth and might miss a game.