Thea Brookes (30 not out) and Paige Scholfield (38) shared a 69-run eighth-wicket partnership to leave the hosts needing eight runs from the final over.
However, Hayley Matthews bowled Rebecca Grundy and then Beth Langston was caught, with Lightning all out for 158.
Thunder had posted an imposing 164-8 after Amy Satterthwaite's half-century and Deandra Dottin's quickfire 42.
A close run chase from Lightning had looked unlikely when captain Georgia Elwiss (20) was run out at the non-striker's end and the hosts slipped to 57-4.
England spinner Sophie Ecclestone's 3-23 then reduced Loughborough to 88-7 but Brookes and Scholfield looked to counter-attack - striking eight fours and a six as they brought up their fifty partnership from only 28 balls.
Despite Scholfield being reprieved on 36 when she was dropped by Nat Brown, she was bowled by Dottin off the next ball as the enthralling game swung one final time in Lancashire's favour.
Both sides now have one victory and one defeat after their first two matches, but Lightning remain above Thunder thanks to their bonus-point win in the league's inaugural match on 30 July.

The paper said that during the first five months of this year, 385 people - more than two a day - were killed.
The number of black people was disproportionately high among the victims, especially unarmed ones.
Official statistics rely on self-reported figures from law enforcement agencies.
They suggest about 400 people have been killed each year since 2008.
The US has seen a number of controversial cases where unarmed black people have been killed by white police officers.
Police are allowed to use deadly force when they fear for their lives or the lives of others, however there is currently no reliable way of tracking police shooting deaths.
Instead, the government relies on self-reported figures from the nation's 17,000 law enforcement agencies. The figures exclude killings deemed not to have been justified.
The Washington Post says it logged every fatal shooting in 2015 by police in the line of duty using interviews, police reports, local media reports and other sources.
It found a homicide rate of almost 2.6 per day so far this year - more than double the average 1.1 deaths per day reported in FBI records over the past decade.
"These shootings are grossly underÂ­reported," former police chief Jim Bueermann told the newspaper. "We are never going to reduce the number of police shootings if we don't begin to accurately track this information."
Among the report's other findings:
Lancashire Thunder edged to a nail-biting six-run victory over Loughborough Lightning at Haslegrave.
[NEXT_CONCEPT]
Data collected by the Washington Post newspaper suggests that the number of people shot by US police is twice as high as official figures claim.