Barcelona’s new coach Quique Setien had started his reign at the club with a 1-0 win over Granada on Sunday, but his side left it until the fifth minute of added time to take the lead in Ibiza.
The new coach had made the decision to leave behind a number of key players, including talisman forward Lionel Messi, and struggled to get into the match, with the home side taking an early lead through Javi Perez.
Barcelona left it late to get back into the match, with Griezmann striking twice in the last 20 minutes to secure the win for Barcelona and prevent a shock defeat.
With their first attacking opportunity of the match, Ibiza took a surprise lead against a side who have won five out of the last eight Copa del Rey titles.
After being fed the ball at the edge of the box by Rai Nascimento, Perez slotted home to put his side ahead, prompting celebrations involving the entire bench.
The home side almost extended their unlikely lead, and had the ball in the back of the net when Angel Rodado rounded a Barcelona defender before shooting ball past Neto, but the goal was disallowed by the referee for a foul by the Ibiza number nine.
Barcelona grew into the game following the disallowed strike, and started to dominate possession, but struggled to turn their control of the ball into clear-cut chances, with the home side putting men behind the ball.
Ibiza had another opportunity to double their lead, with Barcelona too slow to clear the ball, allowing Nascimento to get a shot away which rebounded back off the far post. Rodado followed up on the shot, but Neto managed to just tip the ball over the bar.
Barcelona had to wait until nearly the 70th minute for their first shot on target, but the strike from Ivan Rakitic lacked power and was gathered easily by the Ibiza goalkeeper.
The visitors eventually levelled the tie in the 72nd minute, through Griezmann, who made a clever run behind the home defence before taking a touch and netting.
Deep into injury time, Barcelona finally took the lead for the first time in the match, when Jordi Alba played in Griezmann who shot into the bottom right-hand corner to send his side into the next round.