WEST SACRAMENTO, Calif. — The Boston Red Sox have been on a tear, and Monday night provided another dramatic chapter. Ceddanne Rafaela, the dynamic young outfielder, delivered the defining moment of the game with his first career grand slam in the sixth inning, propelling the Red Sox to a 4-2 victory over the Athletics. The win marked Boston’s 18th in their last 20 games, a surge that has vaulted them back into playoff contention.

For much of the night, it looked like the Athletics’ rookie starter Jack Perkins would be the story. Perkins, who entered with a 2-6 record, silenced the Red Sox bats through five innings, allowing no hits and striking out several Boston hitters. The Athletics gave him a 1-0 lead in the bottom of the first when Tyler Soderstrom, who extended his hitting streak to 10 games, launched his 17th home run of the season off Red Sox starter Payton Tolle. Soderstrom’s blast came two batters into the inning, giving the A’s an early cushion.

Tolle, however, settled in after that. The left-hander worked 5 1/3 innings, allowing two runs on five hits while striking out seven and walking just one. He kept the game close, giving his offense a chance to break through.

That breakthrough came in the sixth. Connor Wong led off with a double to left-center, the first hit of the night for Boston. Perkins then walked Willson Contreras with two outs, putting runners on first and second. Athletics manager Mark Kotsay decided to pull Perkins, who had thrown 95 pitches, and brought in left-hander José Suarez. Suarez immediately walked Wilyer Abreu, loading the bases for Rafaela. On a 1-0 count, Rafaela drove a fastball deep into the left-field seats, sending the Red Sox dugout into a frenzy. The grand slam was his 11th home run of the season and gave Boston a 4-1 lead.

“I was just looking for something to hit hard,” Rafaela said after the game. “He made a mistake, and I didn’t miss it.”

The Athletics responded in the bottom of the sixth. Jonah Heim led off with his 10th home run of the year, a solo shot that cut the deficit to 4-2. That was the last hit Tolle allowed; he was replaced by Justin Slaten, who got the final two outs of the inning. Jovani Morán and Garrett Whitlock each pitched a perfect inning of relief, setting the stage for Aroldis Chapman in the ninth.

Chapman’s outing was not without drama. Colby Thomas led off with a single, and pinch-hitter Nick Kurtz reached on a fielding error by second baseman Anthony Seigler with one out. Chapman, however, bore down and struck out Henry Bolte and Alika Williams to end the game, earning his 25th save in 27 opportunities.

Perkins was charged with two runs on one hit over 5 2/3 innings, walking three and striking out six. The loss dropped the A’s to 3-7 in their last 10 games, and they have now lost 24 of their last 30 overall.

Curtis Mead made his Boston debut, acquired from the Washington Nationals on Saturday for rookie pitcher Connelly Early. He struck out looking in his first at-bat and then left the game after being hit on the wrist by a pitch in his second plate appearance. The severity of the injury was not immediately known.

The Red Sox are now 55-50, sitting just a few games back in the wild-card race. Their next game is Tuesday, with left-hander Jake Bennett (6-3, 2.58 ERA) taking the mound against Athletics lefty Gage Jump (3-6, 4.42).