The Mariners (79-61) are winding down a 10-game road trip, with four games at Tampa Bay (85-56) in a matchup of teams holding American League Wild Card positions.
Castillo and relievers Isaiah Campbell, Matt Brash and Andres Munoz combined on a four-hitter.
In the ninth, the Rays had a chance after Munoz plucked Luke Raley on the foot with a pitch. But Raley was caught trying to steal second by catcher Cal Raleigh. Taylor Walls walked and stole second. But with two outs, Munoz fanned Harold Ramirez for his 12th save.
Both starters were in control, with each working out of early-inning jams.
Castillo (12-7), who won his sixth straight decision, worked around four hits and four walks.
The Rays received a stellar start from Zack Littell (3-5), who logged a career-high eight innings.
Littell has become a solid fixture in Tampa Bay's rotation since being claimed off waivers from the Boston Red Sox on May 12.
Entering Thursday, Littell had gone six innings three times.
The Mariners scratched out their lone run against Littell in the second. Eugenio Suarez led off with a double and advanced to third on Ty France's groundout to second. The Rays played their infield in, and Ford bounced an RBI single to center.
Castillo received a defensive boost to lead off the sixth. Isaac Paredes lifted a towering fly ball to deep left field. Left fielder Dominic Canzone, in full speed, raced to the corner and made a highlight-worthy, sprinting catch before tumbling over the low wall.
The ball was ruled foul, and Canzone, despite the spill, bounced back onto the field. From the mound, Castillo showed his appreciation, and the right-hander recorded consecutive strikeouts of Raley and Walls to conclude his outing.
In the first, Seattle's Teoscar Hernandez singled to right, extending his hitting streak to 16 games.
—Field Level Media