Hibernian 4 Gretna 2
The home side were two goals down just after half-time but substitute Merouane Zemmama turned the game with a brilliant double strike.
Hibs could even afford a second-half penalty miss when Abdessalam Benjelloun shot too close to Greg Fleming.
Hibs almost scored in the opening minute when a slide-rule pass from Guillaume Beuzelin played in Alan O'Brien but he side-footed his shot a yard wide.
A lively run from Filipe Morais almost produced a goal but Beuzelin was just a foot short of connecting with his inviting cross in front of goal.
Benjelloun then scooped a 15-yard shot over the top after good work by Thierry Gatheussi.
It was one-way traffic. Greg Fleming had to move swiftly off his line to save at the feet of O'Brien and then a David Murphy free-kick was just a yard too high.
But it was Gretna who snatched the lead after 17 minutes. Chris Hogg brought Fabian Yantorno down with a clumsy challenge at the edge of the area.
Hibs left Yves Makaba-Makalambay horribly exposed when they elected to play only three men in the wall and Yantorno drilled the ball past the goalkeeper direct from the free-kick.
David Graham had a chance after Gatheussi over-elaborated just outside his own area but his low shot was deflected wide.
Paul Murray then tested the goalkeeper with a long-range effort which Makaba-Maklambay gathered at the second attempt.
Gretna were out-passing Hibs at this stage and the frustrations from the home crowd seemed to translate onto the pitch.
The movement of Colin McMenamin and Yantorno was causing Hibs problems at the back and there was a blow for the home side seven minutes from the break when skipper Rob Jones had to go off with a head knock to be replaced by Torben Joneleit.
Gretna extended their lead four minutes into the second half when Joneleit misjudged a long ball from Craig Barr and McMenamin pounced to tuck the ball past Makaba-Makalambay.
Hibs should have pulled a goal back moments later when Barr handled in the penalty area but Benjeloun's spot-kick was too close to Fleming.
Zemmama pulled a goal back when he slid in at the back post to finish off a driven cross from Benjelloun after 64 minutes.
And two minutes later Steven Fletcher headed the equaliser from a Beuzelin cross with Gretna's marking shabby at the back.
Zemmama made it 3-2 nine minutes from time when he curled in a free-kick to leave Fleming with no chance.
And Kevin McCann made it four in the final minute when he raced through to shoot the ball under the Gretna goalkeeper.