Ramon Pereira sent former club Hearts to their first defeat of the season and out of the CIS Insurance Cup.
Long-range efforts from Livingston's Paul Dalglish and Hearts' Stephen Simmons that flew just wide were the high points of a poor first half.
Striker Pereira slid in to fire home a Derek Adams cross from 15 yards as Livi improved after the break.
The SPL leaders rarely looked like equalising until blocked stoppage-time efforts from Rudi Skacel and Simmons.
Hearts boss George Burley, complaining of mounting injuries and conscious of the next league match being against champions Rangers, gave a debut to young striker Jamie Mole.
He also gave outings to fringe players Simmons, Lee Wallace, Deividas Cesnauskis and Brazilian Samuel Camazzola, who was making his first start after coming on as a substitute at Inverness last weekend.
Hearts had triumphed 4-1 when the sides had met in the league just 10 days previously and the visitors controlled the early stages without causing a real threat.
But, when the first real chance of the match finally arrived after 27 minutes, it was the home side, languishing at the foot of the SPL, that came close to taking the lead.
Pereira played in Dalglish with an astute defence-splitting pass, but the former Newcastle striker dragged his angled shot from 18 yards wide of the far post.
Simmons gave the visiting fans a little excitement with a turn and shot from the edge of the Livi penalty area that went inches wide.
Adams had already sent a 30-yard snapshot into the arms of goalkeeper Craig Gordon after the break before setting up the winner.
The former Motherwell midfielder curled a cross into the penalty area from wide on the right.
And the Spaniard was first to react, sliding a volley from 15 yards past the Scotland international that would end Hearts' run of eight straight victories this season.
Simmons turned a corner from Livi substitute Richard Brittain just inches past his own post moments later as Hearts looked rattled.
Burley introduced midfielder Skacel, who has scored in all seven league matches this season, and Calum Elliot for Camazzola and Mole on the hour.
Hearts pressed forward, but Dalglish came close to making them pay on the break with a lob that almost cleared Gordon.
The desperate visitors sent defender Andy Webster into attack in an attempt to send the tie into extra-time.
Skacel finally found some space in injury time.
But his close-range drive was blocked by Livingston goalkeeper Roddy McKenzie before Simmons' drive from the rebound deflected off a defender on its way to goal.
Livingston: McKenzie, Pereira, Dorado, Strong, Mackay, Neil Barrett (Brittain 45), Walker (Vincze 79), Adams (Scott 90), Dair, Dalglish, Graham Barrett.
Subs Not Used: Roy, Boyd.
Goal: Pereira 54.
Hearts: Gordon, Neilson, Pressley, Webster, Wallace, Cesnauskis (Berra 73), Camazzola (Skacel 60), Hartley, McAllister, Simmons, Mole (Elliot 60).
Subs Not Used: Mikoliunas, Banks.
Booked: Cesnauskis, Pressley.
Ref: S Dougal