Everton needed an Abdoulaye Doucoure extra-time winner to see off Rotherham 2-1 and avoid an FA Cup third-round upset at Goodison Park.
Carlo Ancelotti left out top scorer Dominic Calvert-Lewin, Richarlison and goalkeeper Jordan Pickford, but their replacements were second-best for much of the 120 minutes at Goodison Park.
Rotherham, with just one win in their previous nine games, made six changes of their own but looked far more cohesive and they deserved more than just Matt Olosunde's maiden senior goal for their efforts.
Cenk Tosun's first strike for Everton since November 2019 was cancelled out just after half-time by the former Manchester United academy graduate, who won a solitary cap for the United States in 2018.
Substitute Doucoure scored the eventual winner three minutes into the additional period but it was far from comfortable for Ancelotti's side, who progressed to the fourth round for only the second time in five seasons.
How Everton limped past Rotherham...
What began with the appearance of a behind-closed-doors friendly arranged primarily for James Rodriguez to sharpen his fitness, given free rein by Ancelotti to roam where he liked, turned into something of an ordeal for Everton.
The Colombia international's movement pulled Rotherham's defence out of position to allow the 19-year-old Anthony Gordon to turn his marker Michael Ihiekwe and his inviting through-ball down the inside-left channel was dinked over the advancing Jamal Blackman by Tosun in the ninth minute.
This week the Turkey international, with one eye on this summer's Euro 2020, said he was considering his future this month and while the goal was a much-needed confidence boost little else about his play suggested he has much to offer Ancelotti.
His goal should have given the hosts a platform but in the 30 minutes to half-time Rotherham were the better side with Robin Olsen making a double save from Olosunde and then Dan Barlaser before Matt Crooks flicked a near-post header onto the roof of the net.
Despite having the lead Everton were second-best for the remainder of the first half and within 10 minutes of the second were made to pay.
Wing-back Olusunde capitalised on a weak Tom Davies header back towards his own goal to turn and fire a shot across Olsen and inside the far post.
Ancelotti sent on Doucoure, Bernard, Yerry Mina - replacing Lucas Digne after his first appearance since ankle surgery in November - and Gylfi Sigurdsson in two quick double substitutions in an attempt to change the momentum.
Everton won their first corner in the 73rd minute from a Rodriguez deflected shot but it was hardly the turnaround the Toffees boss expected.
Tosun thought he had won it three minutes from time by diverting in Rodriguez's free-kick, but the goal was ruled out by VAR for offside.
But three minutes into the additional period there was no denying Doucoure, who slotted home from Rodriguez's pass to make it 2-1. Bernard should have killed off the game but hit the post but the visitors could not force another equaliser.
Opta stats - Doucoure delivers Rotherham blow
Abdoulaye Doucouré's 93rd-minute winner for Everton means Rotherham have now lost each of their last six away FA Cup matches against top-flight opponents by an aggregate scoreline of 2-21.
Cenk Tosun has scored his first goal for Everton since netting a 97th-minute equaliser against Tottenham in the Premier League in November 2019.
What the managers said
Everton assistant manager Duncan Ferguson: "I thought we had the best of the first 25 minutes and then Rotherham came back, pushed us all the way and got the equaliser. It was a tough game for us and one we were delighted to get through."
Rotherham boss Paul Warne: "I was really pleased. The only disappointment for me was the first five or 10 minutes, I think we showed them too much respect which I warned them about in the dressing room. I thought we took the game to them after we conceded and I thought we were the better side in the first half.
"For us to come here and compete against a team three or four points off the top of the Premier League shows how well we performed today so I am proud of that."
FA Cup 2020/21 - key dates and draw
The FA Cup schedule has been confirmed, with the final scheduled at Wembley on Saturday, May 15.
There will be no replays this season to help ease fixture congestion.
The draw for both the fourth and fifth rounds will take place on Monday, January 11, ahead of the third-round tie between Stockport and West Ham.
- Fourth round: Saturday January 23
- Fifth round: Wednesday February 10
- Quarter-finals: Saturday March 20
- Semi-finals: Saturday April 17
- Final: Saturday May 15