In its most heated game yet, the Hudson River Derby has shifted back west — and red.

For the fifth time in six meetings, the Red Bulls beat rival New York City FC. And Sunday’s was a testy, card-filled 4-1 rout at sweltering, sold-out Red Bull Arena, where the mutual bile was on full display.

The Red Bulls (9-9-4, 31 points) got two goals from Bradley Wright-Phillips, and a goal and two assists from Sacha Kljestan to climb into second in the Eastern Conference, just two points behind their blue-clad rivals. And they saw NYCFC’s tempers boil over, with seven of the nine cards and both ejections.

Ethan White got sent off for a second yellow in the 89th minute, and coach Patrick Vieira in the 34th, arguing with Red Bulls coach Jesse Marsch as he coached through a water break before leaving the field, and then again in the postgame hallway when Vieira refused to shake the Marsch’s hand.

“He didn’t want to shake my hand in the hallway. But I’ve seen this from him after the game before,’’ said Marsch. “Now that we’re starting to build history and you’re starting to see hatred, that’s going to add to it for the upcoming games in years to come. That’s what makes rivalries. That’s what makes derby matches. It’s there.”

It’s been there since the Red Bulls’ 7-0 rout in May, when The Post learned several NYCFC players got in the face of Felipe, a Red Bulls player, in the tunnel and threatened him. Multiple Red Bulls told the Post that MLS called them to ask about the incident, with no fines resulting.

“When there is a rivalry, a derby, those things happen. Both teams want to win. That’s soccer,’’ Felipe told The Post. “Whatever happened, I leave in the past and just move forward. But if that is [providing motivation], good for us, bad for them. We just need to keep going and win all the games against them.”

They’ve won all but one, outscoring NYCFC 18-5. And Vieira is convinced the latest result was largely due to the refs having been influenced by Marsch’s accusations that NYCFC’s stars get preferential calls.

“He made more decisions in favor of the Red Bulls because the manager had been crying all the week. In the end he gets what he wanted,’’ said Vieira, adding: “I don’t think it’s appropriate to come out in the week that there’s a derby.

“One day [the ref] is for us; one day he’s against us. We understand it and we respect it. Some people don’t, and they prefer to cry openly.’’

Whatever the case, the Red Bulls rolled. Kljestan slipped a pass through to Wright-Phillips for a 20th-minute goal, and Ronald Zubar headed home Kljerstan’s corner just three minutes later.

When center back Frederic Brilliant — who had a horrid day — committed a handball in the box, Kljestan converted the ensuing penalty. Tommy McNamara scored on a 30-yard laser for NYCFC (9-7-6), but Wright-Phillips tallied again, moving within two of tying Juan Pablo Angel’s team career mark.

“The players don’t like each other, the fans don’t like each other. That’s what derbies are all about,’’ said Red Bulls captain Dax McCarty.

“New York’s a big city, but it’s a very prideful city. We want to be the team. We’ve been here for a long time; we take a lot of pride in that,’’ said Mike Grella. “The intensity was that of a playoff game.”