Substitute Silvestre Varela needed just 82 seconds to fire Portugal on the way to a face-saving World Cup qualifier win over Azerbaijan.
The Porto frontman's 63rd-minute finish, which came almost immediately after he had replaced Miguel Veloso, finally gave the Portuguese the lead in a tense Group F encounter which was not settled until Helder Postiga and Bruno Alves struck inside the final five minutes.
But on a night when luck deserted Paulo Bento's men for long periods, the home side had earlier hit the woodwork on no fewer than four occasions, while Real Madrid superstar Cristiano Ronaldo also saw a series of chances go begging in Braga.
Victory left Portugal locked together with leaders Russia on six points at the top of the group following a resounding 4-0 win in Israel for Fabio Capello's side.
Alves might have fired Portugal ahead within five minutes, but saw his shot from Raul Meireles' corner blocked by Mahir Shukurov, and Azerbaijan keeper Kamran Agayev had to tip Meireles' shot around the post six minutes later.
Postiga rattled the crossbar with an 18th-minute drive and Joao Moutinho repeated the feat five minutes later as Agayev's goal led a charmed life.
The keeper kept the visitors in it with a saves from Moutinho and Veloso, but needed the help of a post to deny Postiga on the stroke of half-time.
Ronaldo was denied by an upright six minutes after the restart and then saw Agayev punch away a 30-yard piledriver with the keeper proving more stubborn than the men in front of him.
The former Manchester United man missed the target from inside the penalty area with 58 minutes played and then saw a 79th-minute overhead kick turned around the post.
Varela eventually opened the scoring with a right-foot finish from 12 yards barely a minute after being called from the bench, and although Agayev kept Nani, Ronaldo and Joao Pereira at bay, the respite was temporary.
Postiga converted Ronaldo's 85th-minute flick-on to ease the nerves and then Alves headed home Moutinho's corner three minutes later as Portugal eased across the finishing line.