Latvala swiped the lead at the end of Friday morning, and went on to extend his advantage by the end of the first full day to 11.1s.
The Finn then came under heavy pressure from Rally Argentina winner Kris Meeke on Saturday morning, before Ogier joined the fray in the afternoon.
The Frenchman had to suffer while sweeping the roads on Friday - his woes compounded by an early puncture - but remained in contention and fought back when Rally 2 returnees ran ahead of him.
Portugal Rally
Ogier closes on Latvala in Portugal
23/05/2015 AT 17:32
Ogier moved up to second, 9.5s behind Latvala, heading into the final day after winning three consecutive stages and took another 1.7s out of him on Sunday morning's Fafe test, back on the calendar for the first time since 2001.
But Latvala rallied and went quicker than Ogier on Vieira do Minho, carrying a 10.4s lead into the powerstage that proved to be decisive.
Ogier bagged the three points available there but was only 2.2s faster than Latvala, as the Volkswagens sweeped the top three positions both on the stage and on the rally to bounce back from a torrid Rally Argentina in style.
Andreas Mikkelsen secured third, in-part thanks to Kris Meeke suffering a broken anti-roll bar on the penultimate stage. Mikkelsen had moved into third and 0.4s ahead of Meeke on the preceding stage when the issue cost Meeke more than 16s.
Ott Tanak gave the new-spec Fiesta a successful debut, bringing the new car home fifth and showing flashes of real pace in what M-Sport hopes is a title challenging Fiesta.
The sixth placed spot was secured in the final few stages, as Mads Ostberg, who had moved past Haydon Paddon into seventh on Sunday's Fafe opener, moved to within 5s of Dani Sordo going into the power stage. Sordo held on heading the Norwegian by 4.3s overall.
Paddon secured eighth ahead of the new-spec Fiestas of Robert Kubica and Martin Prokop.
The WRC2 battle went down to the wire, as 2014 champion Nasser Al-Attiyah fought off a late charge Esapekka Lappi on the new Skoda Fabia R5's debut.
Leading positions after SS16:
Leading powerstage times:
Championship standings:
Portugal Rally
Jari-Matti Latvala builds Rally Portugal lead
22/05/2015 AT 19:28
Portugal Rally
Rally Portugal stage cut due to fires
22/05/2015 AT 14:26