A laugher suddenly wasn’t so funny for manager Joe Girardi and the Yankees Wednesday night.

An early seven-run bulge was whittled to four and the Cardinals had a runner on second with two outs in the eighth.

Knowing a loss would have crushed his club, Girardi summoned David Robertson from the bullpen in a non-save situation and asked the closer for four outs.

After giving up an RBI single to Kolten Wong that cut the lead to three, Robertson fanned Matt Holliday to end the eighth. He allowed the first two runners to reach in the ninth as the anxiety in the Yankees’ dugout rose. But Robertson fanned the final three batters to seal a 7-4 victory that before a sold-out Busch Stadium crowd of 45,267.

“I feel pretty good physically,’’ said Robertson, who was used before the ninth for the fourth time this season. “I wasn’t getting more ground ball outs, quick outs.’’

The victory sent the Yankees into Thursday’s day of rest with a 5-4 road trip, but it was more difficult than it should have been.

Before the top of the seventh the Cardinals played a video tribute of the retiring Derek Jeter, who didn’t play, and then trained the camera on him in the dugout. The fans reacted with a standing ovation and Jeter came out of the dugout, doffed his cap and pointed toward the Cardinals’ first-base dugout.

“We were winning and I thought it was appropriate,’’ Jeter said of taking a curtain call.

When the Yankees led 7-0 after four innings, it appeared they would coast to a victory. But Hiroki Kuroda couldn’t get out of the sixth. In 5 ²/₃ innings he allowed three runs and nine hits.