During a first half of few chances, Larne had a big opportunity to break the deadlock in the 14th minute when Ryan Nolan nodded Sean Graham's deep corner back for Shaun Want, whose header pinged off the crossbar.
Linfield broke the deadlock with their first chance of the game when teenager Thompson fired home the rebound from Rhys Annett's shot, which had been palmed away by Rohan Ferguson.
The home side had a huge opportunity to level just before the break. Stopper David Walsh came off his line to try thwart a Larne chance, but misjudged Tiarnan O'Connor's header.
The loose ball then fell to O'Connor, with Sam Roscoe making a crucial clearance off the line to deny the striker.
After the restart, Kieran Offord tried to give Linfield a more comfortable lead, but his shot was blocked by Cian Bolger before the striker sent a curling effort just wide shortly after.
Walsh was then called into action to thwart O'Connor's strike after he had burst into the box.
Larne levelled the game in the 79th minute when the unmarked Ryan fired home Cricky Gallagher's low delivery past the outstretched Walsh.
Gary Haveron's side took the lead on 88 minutes when Linfield failed to clear Mark Randall's corner which eventually fell to McKendry, whose first-time finish found the top left-hand corner.
Linfield continued to push for a leveller until the final whistle with the away fans shouting for a penalty when Offord fell under the challenge of Tomas Cosgrove, but the appeals were waved away.