It was beyond brutal in Philadelphia the previous time Yu Darvish pitched. He exited that game after seven scoreless innings, then watched in what had to be utter amazement as his Cubs teammates blew a five-run lead and lost to the Phillies, who scored six runs in the ninth inning.

With luck like that, who needs any?

But what a drastically different story it was — for Darvish, and for all the Cubs — in the team’s 12-11 victory Wednesday against the Giants at Wrigley Field.

This time, Darvish’s team had his back in a big way, scoring seven runs in the first five innings. But Darvish — despite becoming the first major-league pitcher since at least 1908 to strike out at least eight batters and walk none in five consecutive starts — came unglued in the sixth.

It all started with an error. Darvish easily beat Alex Dickerson to the bag on a ground ball to Anthony Rizzo, but he dropped the first baseman’s toss. Next came a nine-pitch battle with lefty Stephen Vogt, who ultimately clobbered a home run 416 feet to right field. A Kevin Pillar shot into the basket in center — the Giants’ fourth homer off Darvish — tied it 7-7 and sent him on a slow, lonely walk to the dugout.

On a night when the Wrigley crowd came ready with “Yuuu!” chants — the loudest of which came on his RBI single in the second inning — Darvish left the game with his head down.

“Four homers is too much,” he said. “But we won, so I’ll take it.”

An army of Cubs rallied to make Darvish’s struggle-filled outing come across as more of a blip than a serious regression. That’s the difference between winning and losing, isn’t it?

And this was no ordinary victory. The Cubs’ fourth win in a row — which moved them a half-game ahead of the Cardinals at the top of the National League Central — felt to players like a momentous one.

Kris Bryant, whose two-run homer in the eighth was the final scoring blow of the evening, described it as “season-defining.”

“Yeah, that’s what [Anthony Rizzo] told me,” he said. “We were high-fiving there, and Rizzo told me this was a season-defining win, and I can’t disagree with him. It was one of those games where you don’t feel like you’re going to win, just because you’re taking a lead and then giving it back, but we came out on top and definitely had some good momentum here.”

Nick Castellanos had four more hits, including a homer, and drove in three runs. Rizzo had two hits and scored three runs. Brandon Kintzler and closer Craig Kimbrel each pitched a scoreless inning to pick up their teammates on a rough night for pitchers.

The Giants scored a total of nine runs in the fifth, sixth and seventh innings — and lost?

“Just a good, hard-fought, never-quit win for us,” Rizzo said.

But the game didn’t go the way it was supposed to for Darvish, who’d seemingly gone a long way toward reversing his fortunes with the Cubs. Darvish — still with only five victories in 34 starts with the team — came in red-hot, with a 2.36 ERA in his previous seven starts. And he has been in full command, as evidenced by his disappearing walk numbers.

Manager Joe Maddon compared Darvish’s slow start as a Cub to that of Jon Lester, who was good — 11-12 with a 3.34 ERA — but not a true ace in 2015, his first season with the team.

“Now we’re seeing who Yu Darvish really is,” Maddon said before the game.

Needless to say, Darvish hasn’t been anywhere near as good thus far as Lester was then.

Cubs fans have seen Darvish pitch well, and they’ve seen him exit a few games with his head down.

This time — unexpectedly — they saw the latter, quieting any notion that Darvish has found his way out of the woods just yet.