Patryk Klimala celebrates his equalizing goal in the 102nd minute. (Vincent Carchietta-USA TODAY Sports)

In the most dramatic finish in the seven-year history of the Hudson River Derby, the Red Bulls managed to pull out a 1-1 draw with nine-man New York City FC in the 12th minute of injury time at Red Bull Arena Wednesday night.

Patryk Klimala converted an 11th-hour penalty kick to keep the Red Bulls flagging playoff hopes alive. After VAR assistance, it was ruled that NYCFC center back Maxime Chanot was called for a hand ball on a Klimala shot.

After referee Ismail Elfath consulted with VAR, he ruled a PK and Klimala powered a shot into the lower right corner past goalkeeper Sean Johnson.

Klimala’s goal was the latest goal scored in a regular-season game in MLS history, according to a league spokesman.

“I think he’s quality,” Red Bulls head coach Gerhard Struber said. “I expect from him that he scored from the penalty spot. He has the ability.”

“I’m very relieved, thanks to Patrick,” Red Bulls defender John Tolkin said. “I think it just shows the character of the guys. I think it shows that we still have that goal on our mind that’s playoffs and we’re going to do everything we can to get there.”

Castellanos scored the first goal of the match for City, which also had Keaton Parks red carded.

Referee Ismail Elfath certainly had a busy night, whistling 44 fouls – 23 on NYCFC – and doling nine yellow cards, five on the Red Bulls.

NYCFC (11-8-6) moved to 39 points while the Red Bulls (26 points) moved to 7-11-6.

The teams will have three days of rest before meeting again at Yankee Stadium Saturday at 8 p.m.

The opening 15 minutes was evenly played as both sides had chances.

Omid Fernandez had the first for the hosts as his eight-yard shot off a Klimala feed from the left wing was denied by a diving save by Johnson’s diving save in the eighth minute.

On the other side of the pitch, his Red Bulls’ counterpart had an easier time stopping Anton Tinnerholm’s header off a corner kick two minutes later.

Johnson was certainly up for the match as he made a spectacular save on a wicked shot by Wiki Carmona from outside the penalty area in the 22nd minute. The Red Bulls got a corner kick  out of it, but nothing came of it.

In the 24th minute, Maxi Moralez fired a shot from the left side, but Coronel knocked it away before pouncing on a loose ball before an NYCFC player could put in the rebound.

Tinnerholm had an even better opportunity in the 29th minute as he rifled a point-blank attempt at the Red Bulls goal of which Coronel made a kick save.

Slowly, but surely, NYCFC took control of the game and their passing and teamwork finally paid off in the 29thh minute. Moralez slotted a pass to Castellanos on the left side of the box and the striker drilled a shot past Coronel for his team-best 13th goal of the season.

Realizing his team needed a spark in the final 45 minutes, Red Bulls head coach replaced Fernandez and Cristian Casseres, Jr. with Andrew Gutman and Dru Yearwood, respectively.

Castellanos thought he had a brace in the 69th minute but his goal was called back due to a foul by center back Maxime Chanot in the box.

The Red Bulls played the final 27 minutes and stoppage time a man up after Parks was given his marching orders after a  hard foul on Yearwood at midfield. Yearwood eventually was forced from the game with a right foot injury as he needed ice on his ailment.

Three minutes into injury time, the Red Bulls had a free kick outside the area. Sean Nealis headed Sean Davis’ free kick over the goal.