Barcelona s Ferran Torres, centre, celebrates after scoring his side s first goal during a Spanish La Liga soccer match between Elche and Barcelona at the Martinez Valero stadium in Elche, Spain, Sunday, March 6, 2022. AP
Elche took a surprise lead at the Martinez Valero when Fidel capitalised on a Pedri error on the stroke of half-time but Barca came storming back thanks to two substitutes.
Ferran Torres diverted in from close range on the hour before Depay scored an 84th-minute penalty after the striker had drawn Elche's Antonio Barragan into a handball.
Victory sends Barca two points above Real Betis and three clear of Atletico Madrid in the table, before Betis and Atletico face each other in a crucial battle for the top four later on Sunday.
It also continues an impressive run of form for Xavi Hernandez's side, who have not lost in the league since December and came into this game on the back of scoring four times in three consecutive games for the first time since 2017.
When Xavi was appointed in November, Barcelona sat ninth but they might now justifiably have their sights set on Sevilla, who are only seven points ahead in second.
Barcelona had the better of the chances in the first half, the best of them falling to Frenkie de Jong, who darted in behind but failed to beat Edgar Badia.
Then Ousmane Dembele sprinted clear and his lifted shot was parried out to De Jong, whose follow-up was cleared off the line by Diego Gonzalez.
Elche then landed a sucker-punch a minute before half-time as Barca failed to deal with a straight-forward goal-kick downfield and amid the confusion, Pedri poked the ball back, past his own defence and through to Fidel. Fidel took a touch and fired into the far corner.
Barcelona equalised on the hour as they worked the ball from left to right, where Dembele drove to the line and hung up a cross. Jordi Alba was unable to catch the ball cleanly but Torres was perfectly placed to steer in.
Elche were tiring, Barca pushing for a winner and in the 82nd minute they got their chance as Depay wriggled around Barragan, the ball popped up and Barragan instinctively lifted his arm to meet it.
The referee consulted the replay, pointed to the spot and Depay swept the penalty into the top corner.
There was more late drama to come, as Alba and Sergio Busquets were both relieved to see penalty claims for handballs waved away before Guido Carrillo headed towards the corner in the 94th minute. Marc-Andre ter Stegen dived and Barca held on.
(For more sports news and updates, follow Ahram Online Sports on Twitter at @AO_Sports and on Facebook at AhramOnlineSports.)