Luis Enrique made 11 changes with Sunday's (AEDT) El Clasico in mind and watched his side endure a significantly more testing evening than he would have expected.
Barca barely produced a meaningful attempt in the first half and were stunned when David Mainz bundled home for the third-tier host shortly after the break.
The visitor needed a stunning goal from 18-year-old Alena to get back into the game – but it failed to push on to find a winning goal and have now won only two of their last six in all competitions.
Paco Alcacer's poor start to his Barcelona career continued as he made it nine matches without a goal since his $43 million move from Valencia.
The second leg takes place at Camp Nou in three weeks' time.
It was Alcacer who had Barca's first effort, his free-kick from the edge of the area pushed away by home goalkeeper Ivan Buigues in an otherwise quiet start to the match.
Jose Gaspar had a tame shot saved by Jasper Cillessen at the other end, while Borja Lopez – one of three players handed a debut by Luis Enrique - headed over for Barca as they struggled to break down the host despite dominating possession.
A frustrating half for the visitor almost got worse when Hercules' Rojas then headed narrowly wide as the underdog went into the break level.
The home side was awarded a free-kick inches outside the box at the start of the second half when Gaspar was brought down by Lopez, with Cillessen doing well to save the Hercules winger's effort from the set-piece.
And Hercules took a shock lead after 52 minutes. Alvaro Salinas' excellent cross from the left was not dealt with by Barca, allowing Mainz to chest in at the far post.
But that spurred Barca into action only six minutes later, with debutant Alena collecting a pass from captain Rafinha and rifling a magnificent left-footed strike into the far corner from 30 yards.
Buigues saved sharply from Lucas Digne but the match was still level going into the closing stages, prompting Luis Enrique to bring on Andre Gomes, while Nili and Marc Cardona came on to become the head coach's fourth and fifth debutants of the night.
Gomes headed an excellent chance straight at Buigues, who then had to save impressively from Cardona as Barca pushed for a winner.
The young attacker then lashed over a final chance in stoppage-time as Hercules – which was in LaLiga as recently as 2011 - held on for an impressive result.