They’re not called the Cardiac Cosmos for nothing.

After digging an early two-goal deficit, the Cosmos rallied for a dramatic 3-2 victory over the Tampa Bay Rowdies Saturday night.

Second-half sub David Diosa rammed home a right-wing feed from Andres Flores three minutes into stoppage time for the winner.

“It was amazing,” said Diosa, who tallied his second goal of the year after replacing Jairo Arrieta in the 86th minute. “I was thinking that if I was going to come in, I had to do something.”

The Cosmos (11-6-2 overall, 5-2-2 fall season) still had to come up with a big play as their defender Jimmy Mulligan headed Michael Nanchoff’s shot off the goal line seven minutes into added time just before the final whistle.

“I knew he was going to try to curl it to the back post,” said Mulligan of Medford. “I was in the right place at the right time.”

The Cosmos extended their home unbeaten streak to 14 games (13-0-1). Tampa Bay fell to 6-6-6, 2-4-2.

advertisement | advertise on newsday

“This is a group that is capable of doing amazing things,” coach Giovanni Savarese said. “Sometimes we just get a little bit away of where we need to be. We battled. We had a tremendous win, showing a lot of character at home.”

Referee Nima Saghafi turned into one of the busiest men in the North American Soccer League encounter, issuing two red cards and nine yellow cards. Cosmos midfielder Adam Moffat, who converted two penalty kicks, and Tampa’s Darnell King were sent off after tussling in the 72nd minute as both teams finished the match with 10 men.

The Cosmos got off to an awful start, surrendering goals within a four-minute span. First, former English international Joe Cole scored from point-blank range off a left-wing cross by Brazilian midfielder Victor Giro, known as PC, in the 11th minute. PC then beat goalkeeper Jimmy Mauer from a difficult angle on the left side in the 15th minute.

Center back Hunter Freeman said the Cosmos were “a little bit too naive, too nice, and we wound up getting burnt on them.”

Aided by two penalty kicks, the Cosmos pulled even. Moffat buried his first attempt into the right corner after Juan Guerra was called for a handball in the box in the 39th minute. He chose the left corner on his 64th-minute penalty, a line drive that keeper Matt Pickens, who guessed correctly, could not stop.

@NewsdaySports

“Obviously they study where you put them and you can’t put them in the same place all the time,” Moffat said. “You just have to mix it up and hope that you hit it well enough.”