MILAN (AP) -- Inter Milan squandered a two-goal lead but then scored in the last minute of extra time for a 3-2 win over Bologna on Tuesday to reach the Italian Cup semifinals.
Defender Andrea Ranocchia scored the winner in the 120th minute on a rainy night at the San Siro with a header from a corner after Bologna goalkeeper Federico Agliardi had fallen over.
Colombia playmaker Fredy Guarin had put Inter ahead in the 34th and substitute Rodrigo Palacio doubled the lead in the 77th -- with both goals coming from beyond the area -- before Bologna struck back with two late goals.
Italy international Alessandro Diamanti curved a free kick around Inter's wall and in off the crossbar in the 80th, and Manolo Gabbiadini equalized with a volley from close range in the 84th.
Inter will next face Fiorentina or Roma, who play Wednesday. Serie A leader Juventus and second-place Lazio already advanced in the other half of the draw.
Amid a flurry of action, Ranocchia briefly thought he had scored the winner in the 85th, but his effort was ruled out for offside. Earlier, Ranocchia had appeared to injure his left foot.
In the 110th, Inter's 39-year-old captain Javier Zanetti hit the post.
"It seemed like it was over after Palacio's goal, but that's the great thing about football, you never know," Inter coach Andrea Stramaccioni said.
Inter played the final minutes with virtually 10 men, since Antonio Cassano was limping but all three substitutions had been used.
"We really showed our character," Stramaccioni said. "I think in the end we deserved to advance."
Before kickoff, representatives of both clubs honored Hungarian coach Arpad Weisz, who guided Inter to one league title and Bologna to two in the 1920s and 1930s. Weisz, who was Jewish, died at the Auschwitz concentration camp in Poland during World War II.