Nico’s strike came after the 22-year-old Ferran Jutgla, making his full debut, and the 17-year-old Gavi had earlier given Barca a two-goal lead at Camp Nou.
But Elche scored twice in 96 seconds shortly after the hour as Tete Morente and Pere Milla pulled the visitors level, only for Nico to drag Barcelona to a 3-2 victory.
And the result got even better for Barca’s top-four chase after Atletico lost 2-1 away at Sevilla, Lucas Ocampos smashing home in the 88th minute at the Ramon Sanchez Pizjuan to consign Atleti to a third consecutive league defeat.
“It’s a difficult moment but I’m calm,” said Diego Simeone. “I trust in the squad we have.”
Barcelona are now seventh, two points behind Atletico and three behind Rayo Vallecano in fourth, yet having played one game fewer than Rayo.
Sevilla are second, five points behind Real Madrid, who play at home to Cadiz on Sunday.
Gavi’s goal made him Barcelona’s third youngest ever scorer in La Liga at 17 years and 135 days, younger even than Lionel Messi when he opened his account aged 17 years and 331 days.
Jutgla also registered his first professional goal, after coming off the bench last weekend against Osasuna and then scoring against Boca Juniors on Tuesday in the Maradona Cup, an exhibition match held in honour of Diego Maradona.
Nico’s goal completed another exciting night for Barca’s young guns, less than a week after Xavi said his veterans needed to do more, insisting they could not rely on the next generation to deliver every week.
“Gavi, Nico, Abde, (Ronald) Araujo, (Alex) Balde, they are the future of the club,” Xavi said. “I played here when I was 18 and I was scared but they let their personality show.”
Gavi, though, was particularly impressive, the teenager scoring a superb individual goal in the first half, before then assisting Nico’s winner late in the second.
“What’s surprising is his age, he’s 17 and look how he competes,” said Xavi. “Today he made the difference with a goal and an assist. More than anything his work is spectacular. We’re happy to have him and I don’t want to compare him to anyone. There’s no ceiling for him.”
Barcelona were cruising after they scored twice in three minutes. Jutgla had already shown a sharp finish early on but was offside before he headed in Ousmane Dembele’s swinging corner at the front post in the 16th minute.
And in the 19th, it was two, Gavi with a spectacular goal to put his team in control.
He spotted Omar Mascarell approaching behind him when Clement Lenglet played the ball and he flicked it with his right foot away from his marker, his body spinning away into the space. Gavi drove forward and when he reached the edge of the box, fired the ball low into the corner.
But Elche had openings on the break and it was two substitutes that dragged them back into the game just after the hour.
First, a superb counter-attack began down the left as Dembele’s press was beaten too easily and Lucas Boye did well to keep the ball in off the line. He switched it right to Morente, who smashed in.
Only 96 seconds had passed before they were celebrating again, Morente freed again down the right and this time crossing to the back post where Milla’s header could only be palmed in off the post by Marc-Andre ter Stegen.
Frenkie de Jong, linked with an exit in the January transfer window, departed to whistles in the 76th minute but a tense atmosphere turned joyous in the 85th.
Gavi was at the heart of it again, a neat one-two with Dembele sending the teenager to the line, where he had the composure to pull back for Nico who poked in on the stretch.
Atletico almost took a point from Sevilla after Felipe cancelled out a stunning goal from Ivan Rakitic before half-time.
But Sevilla snatched victory at the end, Jules Kounde keeping the ball alive at the back post after a scramble in the box, which allowed Ocampos to slam in from close range.