MILAN — The best and worst of Zlatan Ibrahimovic was on show Tuesday as he scored and later was sent off in AC Milan's 2-1 loss at city rival Inter Milan in the quarterfinals of the Italian Cup.

Ibrahimovic clashed with former teammate Romelu Lukaku at the end of the first half, and he was ejected for a second booking in the 58th minute.

“It (the confrontation) certainly influenced the match, the first booking caused the sending off,” Milan coach Stefano Pioli said. “They’re big enough and ugly enough, I don’t know what they said to each other, it can happen, we need to move past it and think of the next match.”

Lukaku converted a penalty for the equalizer and Christian Eriksen scored the winner deep in stoppage time.

“I haven’t spoken with Romelu yet, but I was a player so I know that during a match things can get heated. Situations can flare up but it’s only right that things then settle,” Inter coach Antonio Conte said.

"I liked seeing Romelu so focused, he is improving from a character point of view. He plays an important role for us and if sometimes he gets angry, then we can only gain from it.”

Inter will play Juventus or Spal in the semifinals. They meet on Wednesday.

The two Milan clubs are also fighting it out in the league, with the Rossoneri leading second-place Inter by two points.

Milan broke the deadlock in the 31st minute when Ibrahimovic controlled the ball on the edge of the area before placing an angled drive between the legs of Inter defender Aleksandar Kolarov. It went in off the base of the far post.

There was a huge argument — and head-to-head clash — between Ibrahimovic and Lukaku on the stroke of halftime and both players were booked. The spat between the former Manchester United teammates continued after the halftime whistle and a visibly furious Lukaku had to be pulled back. Italian television said Milan representatives had denied any allegations of racism in Ibrahimovic's remarks to Lukaku, who is Black.

The yellow card was to prove costly for Ibrahimovic as he was shown another after the break for a tackle on Kolarov and sent off, leaving his side down to 10 men.

And Inter was level 13 minutes later. Leão brought down Nicolò Barella and, after viewing the incident again on the pitchside monitor, the referee pointed to the spot. Lukaku slammed the penalty into the top left corner.

The match had a lengthy delay as referee Paolo Valeri received treatment for a thigh injury and was eventually replaced by the fourth official.

Milan goalkeeper Ciprian Tatarusanu pulled off a number of saves but it wasn't enough. Just as the match appeared to be heading into extra time, Eriksen curled a free kick into the top left corner in the seventh minute of stoppage time.

Eriksen’s short-lived Inter career was expected to end this month after club CEO Giuseppe Marotta confirmed the midfielder is among the players the Nerazzurri are willing to sell. But Conte said the 28-year-old Eriksen remains in his plans.

“He is part of the project,” Conte said. "I urged him to take the free-kick, he’s a bit shy but I hope this goal helps him. We all want him to do well because he’s a good lad, perhaps too good.

"We’re keeping a close eye on him as he is part of the group. We’ll all keep working hard right until the end.”

___

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