Cristiano Ronaldo was left on the bench for the visitors in preparation for Tuesday's crucial showdown with group leaders Switzerland, but after a goalless first half the talisman came on and spared Portugal's blushes with the opening goal of the game.
Andre Silva then added a late second for the visitors to give Fernando Santos's side a result which takes them into Tuesday's match knowing that victory would see them clinch top spot in Group B, but anything less than a win would consign them to the playoffs.
Switzerland, who remain perfect with nine wins from nine, wasted no time in building a lead against Hungary during their match, but things were slower to get going for Portugal and it wasn't until shortly before the half-hour mark that they threatened for the first time against the minnows of Andorra.
Ricardo Quaresma sent a header narrowly wide to spark a flurry of chances for the visitors, with Quaresma also being denied by goalkeeper Josep Gomes before Silva fired narrowly over the crossbar shortly afterwards.
Pepe was the next to come close when he drew another stop from Gomes, but Andorra held out until half time - at which point Santos turned to Ronaldo.
The Real Madrid man was rested due to being just one yellow card away from suspension, but he underlined his undoubted importance to the team by finally breaking the deadlock shortly after the hour mark, stabbing the ball home from close range after it had been hooked into his path.
The goal saw Ronaldo equal Robert Lewandowski's all-time record of 15 in a single World Cup qualifying campaign, five of which have come against Andorra following his four-goal show in the reverse fixture.
It was also Ronaldo's 79th goal for his country, lifting him up to joint-third in the all-time list of international goalscorers, and he came close to extending his tally further with a long-range strike in the final five minutes which needed to be saved.
The four-time Ballon d'Or winner was heavily involved when the second did arrive moments later, though, playing a cross to the far post which was knocked back across goal for Silva to tuck home from close range.
Portugal will next host Switzerland knowing that their superior goal difference means that only a win is needed to top Group B.body check tags ::