The duo each homered in the second game to lead the Yankees to a 2-0 victory.
The Yankees now sit tied with the Oakland Athletics for first place in the American League Wild Card standings. Both teams are five games behind the first-place Tampa Bay Rays in the American League East division standings.
"It's a team that has a lot of heart and is playing with a lot of confidence," Yankees manager Aaron Boone told reporters.
"But we've got a long way to go. We've got to keep the foot down on the gas and continue to grind away. It's going to be a tough road ahead."
Yankees shortstop Andrew Velazquez gave his team an early edge with a two-run double in the bottom of the second inning in the first matchup. Red Sox shortstop Xander Bogaerts answered with another two-run single in the top of the third.
Catcher Christian Vazquez then gave the Red Sox the lead with a 409-foot solo homer run to left field in the top of the fifth. Voit and Stanton sparked the Yankees rally in the bottom of the inning.
Josh Taylor entered the game to replace Whitlock, but he issued a walk to Joey Gallo in his first exchange, which loaded the bases.
Voit proceeded to smack the next pitch to right field to drive in Gardner and Judge for the tying and go-ahead runs.
Stanton entered the game as a pinch hitter for the next at-bat. He hit a 3-0 fastball to center field to drive in Gallo for the game's final run.
Yankees third baseman Rougned Odor and utility man Tyler Wade each recorded two hits apiece in the victory. Vazquez went 2 for 3 for the Red Sox.
Red Sox starter Tanner Houck allowed five hits and two runs over four innings in the loss. Yankees starter Jordan Montgomery allowed five hits and three runs in 4 2/3 innings.
Yankees starter Luis Gil held the Red Sox to just three hits over 4 2/3 scoreless innings in the second game of the doubleheader.
The Yankees got on the scoreboard in the bottom of the second. Stanton and Odor started the half-inning with strikeouts, which brought Voit to the plate.
The Yankees first baseman hit the first pitch he saw from Red Sox starter Nathan Eovaldi to right field for a 369-foot solo homer.
Stanton brought in the final run of the game with a leadoff homer in the bottom of the fourth. The Yankees outfielder went down 0-2 in the count against Eovaldi in that exchange. He then smacked a 79.6-mph curveball to left center field for a 441-foot bomb.
LeMahieu was the only player to record more than one hit in the second game. The Yankees infielder went 2 for 3 in the victory. Eovaldi allowed seven hits and two runs over five innings for the Red Sox.
The Yankees (68-52) host the Red Sox (69-53) in the final game of the series at 7:05 p.m. EDT Wednesday at Yankee Stadium.