The visitors were stunned after just six minutes of the Group B clash at the new Estadi Nacional, when Neil Taylor was adjudged to have fouled Ivan Lorenzo in the box and defender Ildefons Lima stuck away the resulting penalty.
That was Andorra’s first competitive goal for four years, and Wales were finding it tricky to get their passing game going on the artificial 3G surface against opponents ranked 199th in the world.
However, Bale directed a header past goalkeeper Ferran Pol from a deep left-wing cross by Ben Davies on 22 minutes to produce the equaliser.
There were some boos from the 1,500 travelling fans towards Chris Coleman as the teams went off at the interval.
And Wales continued to huff and puff after the break – but Bale came to their rescue again in the 81st minute, when he sent a free-kick over the Andorran wall from 25 yards out and to the left of the diving Pol to put the visitors in front.
Bale was one of four changes to the Wales starting XI following their last outing, the 2-0 friendly defeat away to Holland before the World Cup. Aaron Ramsey, Ashley Williams and Ben Davies also returned to Coleman’s line-up, with Joe Ledley, Jonny Williams and Danny Gabbidon dropping to the bench and Hal Robson-Kanu (knee) absent.
The turf had generated plenty of headlines in the build-up to the game and it was clearly far from perfect, but Wales fashioned the first chance inside 45 seconds.
Ramsey found Chris Gunter down the right with a raking pass and the full-back forced Pol into a smart save at the near post.
But Wales were stunned after five minutes when Andorra scored their first competitive goal since September 2010 courtesy of a controversial penalty.
Lima flicked on a long throw and Taylor was adjudged to have pulled back Lorenzo, not by Slovenian referee Slavko Vincic but by one of the officials behind the goal.
Lima sent Wayne Hennessey the wrong way from the spot to spark wild celebrations among the Andorra team.
Wales were visibly shocked, but equalised on 22 minutes when Davies crossed from the left and Bale beat his marker to head firmly into the corner.
Bale’s 13th goal for his country settled Wales and Ramsey cut into the area to send Andorra alarm bells ringing, but the hosts just managed to smother the danger.
The Real Madrid star was dropping deep trying to influence matters, but Andorra were not overawed and in burly striker Gabriel Riera had a focal point for crosses swung into the Welsh box.
Riera troubled Ashley Williams from one such delivery and James Chester had to react quickly to prevent a goal-scoring opportunity.
Wales were struggling to penetrate a tight Andorra defence, but the same Davies-Bale combination which had worked for the goal almost paid off again close to half-time.
Davies swung over another excellent cross, but this time Bale was eased off the ball.
Joe Allen was booked in the closing stages of the half after becoming involved in a tussle with Andorra’s Edu Peppe.
Wales came out with more intent at the start of the second half and Andorra had to deal with a couple of dangerous set-pieces.
And they must have feared the worst when Bale lined himself up over a 57th minute free-kick after the Madrid man had been pushed to the ground.
Bale’s shot dipped in front of goalkeeper Pol who just about managed to push the ball to safety.
But Wales picked up the loose ball and Bale crossed into the centre where Andy King rose well, but could not divert his header goalward.
Coleman sent on Ledley for Simon Church after 62 minutes and Wales were sending men forward in search of a second while being at risk of being exposed on the break.
Williams almost capitalised on a Bale cross, but he was denied by brave Andorra defending while claims for a penalty for handball were waved away by referee Vincic.
Wales forced plenty of set-pieces, even if chances were not in plentiful supply.
But Andorra escaped when Ramsey’s corner caused panic in their penalty area and Bale’s back header was cleared off the line with Ledley bearing down on the dropping ball.
There was a moment of real concern at the other end when Williams hesitated and scuffed his clearance and Wales made the most of their good fortune after 81 minutes.
Bale was felled to win a free-kick which was just about saved by Pol.
But Bale was given a second chance as Riera had raced out too quickly and this time the winger smashed his effort home, the ensuing pitch invasion from Wales fans probably borne out of relief as much as joy.
Ramsey sustained what looked to be a calf injury in the closing stages, as Wales comfortably kept Andorra at bay to take all three points.
Next up for Coleman’s men is a Cardiff encounter on October 10 against Bosnia-Herzegovina, who surprisingly lost 2-1 to Cyprus in Zenica on Tuesday.