Fiorentina reached the Italian Cup quarterfinals by beating Napoli 5-2 after extra time on Thursday in a match that included three red cards and a stoppage-time equalizer.

Vincenzo Italiano’s side will next face Atalanta, which beat Venezia 2-0 on Wednesday.

AC Milan was playing Genoa later in another cup match, with the winner set to face either Lazio or Udinese in the final eight.

Fiorentina's Dusan Vlahovic celebrates scoring during the Italian Cup, round of 16 soccer match between Napoli and Fiorentina, at the Diego Armando Maradona stadium in Naples, Italy, Thursday, Jan. 13, 2022. (Alessandro GarofaloLaPresse via AP)

Fiorentina's Dusan Vlahovic celebrates scoring during the Italian Cup, round of 16 soccer match between Napoli and Fiorentina, at the Diego Armando Maradona stadium in Naples, Italy, Thursday, Jan. 13, 2022. (Alessandro GarofaloLaPresse via AP)

The match in Naples burst into life shortly before halftime when Dušan Vlahović broke the deadlock but Dries Mertens curled in an equalizer for Napoli moments later. The match appeared to have swung in the home side’s favor when Fiorentina goalkeeper Bartłomiej Drągowski fouled Eljif Elmas outside his area and was sent off for a straight red card.

But 10-man Fiorentina restored its lead in the 57th minute when Cristiano Biraghi’s free kick went into the wall and back to him for a curled effort that went in off the inside of the post.

Napoli forward Hirving Lozano was then shown a straight red card six minutes from time for a foul on Nicolás González and midfielder Fabián Ruiz was also sent off in stoppage-time following a second yellow card, leaving the home side with nine men.

Napoli's Andrea Petagna, right celebrates scoring during the Italian Cup, round of 16 soccer match between Napoli and Fiorentina, at the Diego Armando Maradona stadium in Naples, Italy, Thursday, Jan. 13, 2022. (Alessandro GarofaloLaPresse via AP)

Napoli's Andrea Petagna, right celebrates scoring during the Italian Cup, round of 16 soccer match between Napoli and Fiorentina, at the Diego Armando Maradona stadium in Naples, Italy, Thursday, Jan. 13, 2022. (Alessandro GarofaloLaPresse via AP)

But moments later, Andrea Petagna swept home a cross to force extra time.

However, Lorenzo Venuti scored and set up another for debutant Krzysztof Piątek in extra time. Napoli then capitulated and conceded a fifth to Youssef Maleh at the end.

More AP soccer: https://apnews.com/hub/soccer and https://twitter.com/AP_Sports