Palermo's Luca Rigoni, center, celebrates with his teammates after scoring during a Serie A soccer match between Palermo and Fiorentina in Palermo, Italy, Sunday, May 24, 2015. Fiorentina won 3-2 at Palermo to ensure qualification for the Europa League Sunday after Sampdoria was held 1-1 at Empoli earlier in the penultimate Serie A round of the season. (Franco Lannino/ANSA via AP)
Sampdoria President Massimo Ferrero points to supporters prior to the start of a Serie A soccer match between Empoli and Sampdoria at the Carlo Castellani stadium in Empoli, Italy, Sunday, May 24, 2015. (Fabio Muzzi/ANSA via AP)
Empoliâ€™s Piotr Zielinski, right, fights for the ball with Sampdoria's Luis Muriel during a Serie A soccer match between Empoli and Sampdoria at the Carlo Castellani stadium in Empoli, Italy, Sunday, May 24, 2015. (Fabio Muzzi/ANSA via AP)
MILAN — Fiorentina won 3-2 at Palermo to ensure qualification for the Europa League on Sunday after Sampdoria was held 1-1 at Empoli earlier in the penultimate round of the Serie A season.
Marcos Alonso netted the winner 11 minutes from time after Fiorentina had twice been pegged back.
Josip Ilicic, who had been roundly jeered by the Palermo fans, scored a stunning opener against his former club — and even the home fans applauded.
Fiorentina moved back into fifth spot and cannot be caught by seventh-place Sampdoria, which could still qualify for Europe if Genoa fails in its appeal against a decision to deny it a UEFA license.
Elsewhere, veteran forward Luca Toni netted twice in Hellas Verona's 2-2 draw at already-relegated Parma to boost his challenge for the top scorer award.
Toni, who turns 38 on Tuesday, took his tally to 21 Serie A goals this season, putting him one ahead of Carlos Tevez and Mauro Icardi going into the final round.
Cagliari won 1-0 at Cesena in a match between the other two relegated sides, while Sassuolo beat 10-man Udinese 1-0 and Chievo Verona drew 1-1 at home to Atalanta.
Ilicic spent three years at Palermo before moving to Fiorentina in July 2013 and he came back to haunt his former team with a screamer of a goal from 30 yards (meters) which flew into the top left corner.
The Slovenia midfielder didn't celebrate, waving an apology to the Palermo supporters, who applauded the quality of the goal. Ilicic was clearly emotional and even appeared to be crying.
Palermo leveled almost immediately when Mato Jajalo volleyed a powerful shot under the crossbar from the edge of the area.
Fiorentina swiftly restored its lead when Alberto Gilardino redirected Mati Fernandez's snapshot, and Gonzalo Rodriguez thought he had extended its advantage minutes later but the goal was harshly ruled out for an adjudged foul in the buildup.
Luca Rigoni leveled in the 69th minute after the Fiorentina defense failed to deal with a corner but Alonso scored the winner after Gilardino knocked down Ilicic's free kick.
The only downside for Fiorentina was the dismissal of Jasmin Kurtic in stoppage time after the former Palermo midfielder earned two yellow cards in as many minutes.
Sampdoria had been challenging for the top three a few months ago but a run of one win in its previous eight matches had left it outside the Europa League spots.
Empoli, which had earlier hit the bar through Matias Vecino, took a deserved lead just before the hour mark when Manuel Pucciarelli ran onto Massimo Maccarone's long ball and drilled it into the far bottom corner.
Samuel Eto'o snatched a last-gasp equalizer for only his second goal since his arrival from Everton in January.
El Shaarawy, who had been rated as one of Italy's most promising players two years ago, was given his first start since January and the 22-year-old gave Milan the lead in the 18th minute, controlling a Cristian Zaccardo cross on the edge of the box before firing into the bottom left corner for his first goal at San Siro since December 2012.
Milan appeared to have thrown the match away at the end of the first half when Zaccardo was sent off for bringing down Cristian Molinaro when the Torino defender was going clear on goal. It was Milan's 13th red card of the season.
Milan coach Filippo Inzaghi was also dismissed during the interval as he complained that play should have been stopped in the build up to Zaccardo's dismissal as Amauri was offside.
The match turned 11 minutes into the second half when Torino was also reduced to 10 men after Molinaro clattered into the back of Marco van Ginkel in the penalty area.
Giampaolo Pazzini drilled a powerful penalty down the middle for his 100th Serie A goal, celebrating with a special shirt that had the number on it and his nickname "Pazzo" — which also means crazy in Italian.
El Shaarawy doubled his tally in the 65th following a delightful one-two with Van Ginkel — bagging his first brace since November 2012.