PHOENIX -- Tampa Bay's bullpen has had better nights.
After blowing an early 3-1 lead, the Rays lost an 8-7 lead in the eighth and that cost them the game as the D-backs took a 9-8 decision Wednesday night at Chase Field.
"Give them credit, man," Rays manager Joe Maddon said. "They played really well. They fought well. It was a very entertaining baseball game. It was something we don't normally do, give things up in the bullpen. We did tonight. But I have a lot of faith in our guys. The Diamondbacks had themselves a pretty good night."
In defeat, the Rays (66-47) were swept for the first time since losing twice at Kansas City (April 30-May 1), and they have now lost four of their past six games after winning 19 of 22 prior to that.
Meanwhile, Boston took care of Houston with a come-from-behind 7-5 win that expanded the lead of American League East-leading Red Sox to 2 1/2 games over the second-place Rays.
Pitching in his second inning of relief, Joel Peralta walked Didi Gregorius with one out in the eighth to start the winning rally. Pinch-hitter Gerardo Parra followed with a single to center to chase Peralta.
"They have good hitters there," Peralta said. "They are a good team. They got to us. After we got the lead, I came in the seventh, got three outs. Come into the eighth, feeling good. And I lost the second hitter and the next guy got a base hit off me. The walk was the worst part about it. I shouldn't have walked that guy. It happens."
Fernando Rodney entered the game and walked Adam Eaton before Martin Prado singled to right to complete a 4-for-4 night while driving home Gregorius and Parra to give the D-backs a one-run lead that would hold.
"Rodney made good pitches," Peralta said. "The guy got jammed and he gets a base hit. It's just one of those days."
Rodney quickly issued strike one, which set the tone for Prado's approach.
"He threw a pretty good first pitch and then I just thought I wanted to put the ball in play," Prado said. "Second pitch, he left a ball up a little bit, and I put a pretty good swing on it."
Tampa Bay began the evening on a high note when they jumped on Arizona starter Randall Delgado with three runs in the first via an RBI double by Matt Joyce and a two-run double by Yunel Escobar.
Paul Goldschmidt answered for the D-backs with an RBI single in the first to cut the Rays' lead to 3-1.
Rays starter Chris Archer retired the first two batters he faced in the second before leaving the game with right forearm tightness. Alex Torres took over and got out of the second, but in the third he surrendered a two-run homer to Prado and an RBI double to Aaron Hill to put Arizona up 4-3.
The D-backs got an unlikely 6-4-3 double play -- one of six they turned on the night -- in the fourth, which proved to be big as Kelly Johnson followed with his 16th homer of the season to tie the score at 4.
Kyle Farnsworth started the fifth for the Rays and surrendered a single to Eaton and a double to Prado before Goldschmidt lined out to shortstop. Maddon had seen enough and brought in Jake McGee with runners on second and third, but it was more of the same.
Eric Chavez greeted McGee with an RBI single. Hill added an RBI double and Wil Nieves a sacrifice fly to put the D-backs up 7-4.
Jose Molina's infield single off Josh Collmenter with one out in the seventh ignited the Rays' seventh-inning rally.
Pinch-hitter Luke Scott followed with a bunt single before Ben Zobrist grounded into a forceout, leaving runners at the corners with two outs. After Joyce drew a walk, Will Harris replaced Collmenter and Evan Longoria greeted him with a two-run double.
Sam Fuld then pinch-hit for Wil Myers, who had to leave the game due to symptoms of asthma. D-backs manager Kirk Gibson countered by bringing in left-hander Joe Thatcher. Fuld laced a double to left on the first pitch to drive home two and put the Rays up 8-7.
"This was a boxing match tonight, they punched us, we punched back, it was nice to get the knockout blow," Eaton said.
Bill Chastain is a reporter for MLB.com. This story was not subject to the approval of Major League Baseball or its clubs.