Dani Pedrosa finished third, with Valentino Rossi edging Alvaro Bautista in another last-lap fight to secure fourth. Home favourite Cal Crutchlow could only take seventh.
Marquez had not even been certain to start the race after dislocating his shoulder in the Sunday morning warm-up, but in the event was able to shadow Lorenzo throughout and surge into the lead several times over the final laps, the pair staging an absolute classic at the front.
Lorenzo was never able to pull a gap of more than 0.3 seconds, but led uncontested for the first 17 laps after picking off Marquez's Honda at the start.
The 20-year-old, chasing a fifth consecutive win, began to look more aggressive as the race progressed however and with two laps to go he finally stole ahead at Brooklands - diving down the inside of the Yamaha and forcing Lorenzo to sit up mid-corner.
Pedrosa was ostensibly involved in the lead scrap and immediately closed onto Lorenzo's tail, but - as was the case at Brno - was unable to properly join the fight.
Lorenzo fought back immediately, repassing Marquez at Vale to hold the lead onto the last lap.
Still it was not done: while Marquez looked to have lost ground, a fantastic exit onto the Wellington Straight allowed him to close onto Lorenzo and stage a dramatic finish.
Marquez initially picked the outside line, but scythed down the inside at the last minute to snatch the lead just two corners from the flag.
Lorenzo stuck it out round the outside, and while Marquez still led going into Luffield his entry was compromised and Lorenzo snuck back ahead before winning the drag down to the line, with just 0.081s to choose between the pair at the flag.
Pedrosa ultimately paid for his poor start, which meant he had to close a two-second gap to the leaders early on in the race and left him with little ammunition to join the late attacks.
Marquez therefore extended his championship lead to 30 points over Pedrosa - the unlikeliest of scenarios when examinations revealed his dislocated shoulder just three hours before the race's start.
Rossi's fourth was secured by an even closer margin, the Italian just six hundredths of a second ahead of Bautista at the line.
Stefan Bradl had held third early on, but on the softer rear tyre faded late on and came home a relatively quiet sixth.
Crutchlow took a lonely seventh, having never been a factor at the front.
Nicky Hayden meanwhile claimed eighth, but only after Andrea Dovizioso crashed out while battling with Bradley Smith for the position. The Briton was ninth.