Hamza Rafia scored the winner on his debut as Juventus needed extra time to beat Genoa 3-2 and reach the quarter-finals of the Coppa Italia.
A much-changed Juve side were a cut above Serie A strugglers Genoa in the first half at Allianz Stadium on Wednesday, but made hard work of setting up a last-eight tie against Sassuolo or SPAL.
Dejan Kulusevski was outstanding in the opening 45 minutes, scoring inside two minutes and laying on a second goal for Alvaro Morata.
Lennart Czyborra pulled a goal back from out of the blue in an otherwise one-sided first half and Filippo Melegoni later equalised, but 21-year-old Tunisia international Rafia came off the bench to settle the tie late in the first half of extra time.
Kulusevski got the Turin giants off to a dream start, controlling an incisive pass from Giorgio Chiellini superbly with his right foot and firing home with his left.
Genoa were unable to live with Juve's intensity and Kulusevski was denied by Alberto Paleari when he went one-on-one with the Genoa goalkeeper, but Morata was on target 23 minutes in.
Kulusevski turned provider on this occasion, helping another pinpoint ball from Chiellini into the Spanish striker's path with a sublime cushioned pass and Morata kept his composure to beat Paleari at his near post.
Juve were totally dominant but Czyborra got Genoa back in it when he stole in at the back post to head home Edoardo Goldaniga's cross totally against the run of play, before Arthur and Manolo Portanova had goals ruled out for offside in a pulsating first half.
Paleari kept out Morata's shot at his near post early in the second half, but Genoa were almost level when Marko Pjaca rattled the crossbar from outside the penalty area.
Davide Ballardini's men got back on terms after 74 minutes, though, Melegoni curling beyond Gianluigi Buffon from around 25 yards out with a measured right-footed finish.
Pirlo introduced Cristiano Ronaldo and, although Juve were unable to advance in 90 minutes, Rafia bundled in off Lukas Lerager after Morata had cut the ball back.
Arthur nodded off the line as Genoa fought until the end and Kulusevski could have settled it, but Juve held on to advance.
What does it mean? Bianconeri breathe a sigh of relief
Juve were cruising at 2-0 up as they bossed the first half, but their failure to add further goals could have come back to bite them.
Pirlo would have hoped to keep Ronaldo on the bench with a Serie A clash against fellow title hopefuls Inter to come this weekend, but instead the prolific forward was called upon late in normal time.
They were still able to maintain their perfect record this year, though, making it four wins out of four – and scoring 13 goals in the process - the hard way.
Kulusevski stakes his claim
Midfielder Kulusevski staked his claim to become a regular starter with a lively display.
The Sweden international drifted into space intelligently and was a real menace to the Genoa defence, making four key passes and having as many shots on target - the first of which was a clinical finish to open the scoring.
Wesley caught napping
It was not the best of evenings for Juve full-back Wesley, who was caught out of position to allow Czyborra to head home unchallenged.
The Brazilian won only 53.8 per cent of his 13 duels and lost possession 10 times before he was replaced by Ronaldo.
Juve face a mouthwatering trip to second-placed Inter in Serie A on Sunday, while Genoa have a tough test against in-form Atalanta on the same day.