Ben Spelman’s opportunist 16th minute strike after home skipper Jamie Pyper’s short backpass was followed by Mikey Mbewe nodding in a Russell Currie cross on 35 minutes to give the visitors breathing space.
But half-time substitute Lewis Baker smashed home a perfect Lewis Allan pass before Allan shot in for 2-2 on 66 minutes after brilliant set-up play by another half-time sub, Sean Stewart.
And the miracle comeback, in front of 342 fans, was completed eight minutes later when Allan knocked into an empty net after Lewis Baker had won the ball from Gretna keeper Jack Main.
“It was a poor first half performance by us,” Berwick gaffer Stuart Malcolm told the Berwickshire News.
"No disrespect to Gretna, they were good. But we were very, very poor.
"We didn’t turn up in the first 45 minutes and could have made 10 substitutions minus the goalkeeper.
"We were probably lucky that we didn't concede more goals. Our goalkeeper’s had a couple of saves to make as well.
"Second half we changed a few things around. We adjusted what we were doing and probably just asked them to be competitive against the players we were playing against and add intensity when they ran forward and back.
"Simple changes and a change in shape was probably enough to get us back in the game.
"The second half performance was very pleasing.”
Sub Baker earned particular plaudits from his boss.
"Lewis Baker came on and changed the game,” Malcolm added. “He had been ill through the week.
"He came on as a sub on the Tuesday night and was struggling after the game.
"He would probably have played more part in Saturday’s game if he hadn’t been ill through that week.
"I was very pleased for him. He got a goal then helped Lewis Allan get a couple of goals.
"Allan’s second half performance was excellent. He really showed intensity and quality.”
Berwick’s second straight league win – they also beat Celtic B 1-0 – came after a disappointing 6-0 opening day loss at Hearts B.
Malcolm, speaking ahead of a trip to Tranent Juniors in the league tonight (Tuesday) said: “After the start we had on the Saturday against Hearts, we’ve shown a real bit of resilience and character in both games to go and get maximum points.
“We go into tonight’s game against Tranent still kind of light on squad numbers and with illnesses, injuries and concussions and stuff that’s going on within the squad.
"We really need to show bundles of character and enthusiasm.
"We are still early in the season and we’re needing to be building momentum.”
Meanwhile, Berwick have signed striker Martin Rennie on a short-term loan from Montrose.
Malcolm said: “Martin has been a League 1 player a lot of his career. He’s had a good move to St Patrick’s Athletic (his last club before joining Montrose), who paid a considerable amount of money for him.
"Then he came back for personal reasons. We are delighted to get him.
"He’s had a few injury problems the last year so Montrose have helped us get him on loan.
"We’re looking to help them as well and he’s an excellent football player.
"He can score goals, he can link the play at times, he’s a big presence. So he is going to help us over the next four weeks and hopefully get a few goals as well.
"He will have to go back to Montrose before the end of the transfer window so he then becomes available for their squad selection.”