AC Milan scored a 120th-minute equaliser and then came out on top in a 24-penalty shootout to beat Rio Ave and reach the Europa League group stage.
Trailing 2-1 in the final seconds of extra time the visitors were awarded a penalty, which Hakan Calhanoglu converted.
That took the game to a shootout, with Milan coming out on top 9-8 in the 12th round of spot kicks.
The win means AC Milan will go into Friday's group-stage draw.