Tampa Bay, which is tied with Toronto for the second AL wild card, has won five of six.
Patiño (1-1), recalled from Triple-A Durham to make his first big league appearance since July 23, gave up four hits in 5 2/3 scoreless innings. He went on the 60-day injured list following a left oblique strain in April.
“I felt really good," Patiño said through a translator. “I've been in the process of being able to recover from my injuries. Confidence has definitely gone up.”
Patiño gave up three runs and seven hits in four innings at Kansas City on July 23. The right-hander is the Rays' major league-leading 22nd pitcher to win a game this season.
“Kept us off balance,” Royals manager Mike Matheny said. “He's got good stuff. Breaking ball is sharp, good velocity. Couldn't really predict where he was going to go and didn't make a lot of mistakes."
Michael Massey hit his first major league homer leading off the eighth against Shawn Armstrong to stop the Royals' scoreless streak at 33 innings. Kansas City, blanked by Minnesota in its previous two games, avoided being shut out in three straight for the second time this season.
Castillo allowed one run and three hits, including two on bunts, in five innings. The right-hander was acquired from Toronto in the Whit Merrifield trade on Aug. 2 and recalled from Triple-A Omaha to make the start after Keller was shifted to the bullpen on Wednesday.
“Really impressive,” Matheny said. “Couldn't have expected any more than what he did.”
Keller, who went 6-13 in 22 starts this year, entered with one out in the seventh and allowed six consecutive hits, including Díaz's double that bounced over the head of third baseman Bobby Witt Jr. He allowed five runs, six hits and threw a run-scoring wild pitch in two-thirds of an inning.
Roman Quinn had the second hit in the seventh and took advantage of the shift to get a huge lead off first. He advanced to second on Jose Siri's infield single that shortstop Nicky Lopez fielded. Lopez looked at second before making a late throw to first.
“Roman Quinn's baserunning set up that entire inning,” Rays manager Kevin Cash said. “Just very, very heads up. We weren't knocking the ball all over the place. Keller gave up I think six or seven groundballs that inning.”
Christian Bethancourt had a solo homer in the eighth that made it 7-1.
Kansas City designated hitter Vinnie Pasquantino went 0 for 3 with a walk and had his nine-game hitting streak that included five homers end. Salvador Perez walked twice, giving him 12 in 78 games this year.
The Rays arrived in the Tampa area around 5 a.m. after Wednesday night’s 8-7, 10-inning loss to the New York Yankees.
Outfielder David Peralta normally doesn’t sleep on the plane but did this time and said he was snoring so loudly he woke himself up.
Asked before the game if he thought the players were tired, Cash said, “No.”
Royals: RF Hunter Dozier was reinstated from the paternity list.
Rays: SS Wander Franco (right hamate bone surgery) sat out his second consecutive game with Triple-A Durham after departing his first rehab game Tuesday with hand soreness. Cash said Franco will take grounders Friday. ... OF Manuel Margot (right patellar strain) is expected to be activated Saturday. ... LHP Brendan McKay (thoracic outlet syndrome surgery) allowed two runs and two hits over four innings for Durham.
Royals: RHP Brady Singer (6-4), coming off a one-hit, six-inning outing Sunday in a 4-0 win over the Los Angeles Dodgers, starts Friday night against the Rays' Shane McClanahan (11-5), the AL All-Star Game starter.
Padres host the Dodgers to begin 3-game series
Los Angeles Dodgers (106-47, first in the NL West) vs. San Diego Padres (85-68, second in the NL West)
Red Sox look to break 6-game slide, take on the Orioles
Baltimore Orioles (80-73, fourth in the AL East) vs. Boston Red Sox (72-81, fifth in the AL East)
Rangers look to stop slide in game against the Mariners
Texas Rangers (65-87, fourth in the AL West) vs. Seattle Mariners (83-69, second in the AL West)
Phillies look to break road skid, face the Cubs
Philadelphia Phillies (83-69, third in the NL East) vs. Chicago Cubs (67-86, third in the NL Central)
Astros host the Diamondbacks to begin 2-game series
Arizona Diamondbacks (71-83, fourth in the NL West) vs. Houston Astros (101-53, first in the AL West)
Giants take on the Rockies after Davis' 4-hit game
Colorado Rockies (65-88, fifth in the NL West) vs. San Francisco Giants (75-78, third in the NL West)