Setting his sights on Guintoli in the lead, Melandri was initially baulked by the Frenchman as they swapped positions through the opening turns on lap twenty, but after biding his time on the penultimate lap, decided to strike as they entered the final revolution.
Diving through with a neat pass into turn one, Guintoli attempted to respond with a late pass into turn five, only to run wide and allow his rival through again.
Latching onto the tail of the BMW, Guintoli attempted to get a run on Melandri out of the final corner, but whilst he was successful in reeling him in, he would fall a mere 0.007secs shy of snatching it on the line.
As a result, victory sees Melandri lift himself to third in the standings at the expense of a frustrated Laverty, while Guintoli has stretched his advantage over Sykes again to lead by seven points.
Ten seconds down the road, Leon Camier put in an almost unnoticed run to season's best fourth place for Fixi Crescent Suzuki, the Briton recovering from a poor start that left him 15th on the opening lap to claw his way up the order.
Finishing just ten seconds off the lead, Camier would get the better of Loris Baz in fifth position, with Chaz Davies coming home sixth, Michel Fabrizio
seventh and Jules Cluzel in eighth.
Carlos Checa enjoyed a bright start to run sixth initially but would slip back to ninth by the chequered flag, while Federico Sandi, Vittorio Iannuzzo and Ivan Clementi picked up points in tenth, eleventh and twelfth as the only other riders to finish on the lead lap.
Indeed, as well as Laverty and Rea, the first Portimao race would also see Davide Giugliano crash out, a still injured Leon Haslam retire to the pit lane and Ayrton Badovini stop with mechanical problems.