Djokovic stunned by Lajovic in Banja Luka quarter-finals
Djokovic had dropped just four games against the 70th-ranked Lajovic across two previous meetings but was punished for failing to convert three set points in the second-set tie-break.
Lajovic saved 15 of 16 break points overall and won the final five points of the match to condemn Djokovic to another premature exit following his loss in the last 16 of the Monte Carlo Masters.
"I'm overwhelmed," said Lajovic. "It's the biggest win of my career. Beating him is something I didn't even think was possible, but it happened."
As in his opening match, Djokovic started slowly and fell 4-2 behind before finally capitalising on a break point in the eighth game to draw level.
The 22-time Grand Slam champion alluded earlier in the week to the elbow problems which hampered him in Monte Carlo, and Lajovic took advantage of his struggles to break again for a 5-4 lead.
Djokovic had three chances to break back the next game before Lajovic wrapped up the opening set.
Both players held serve throughout the second set despite constant pressure, with Djokovic wriggling out of trouble down 0-40 at four games apiece.
The top seed looked set to force a third set when he surged 6-3 ahead in the tie-break but dumped a routine overhead into the net to offer Lajovic a match point he duly took.
Lajovic, whose lone ATP title came on clay in Umag in 2019, will take on Miomir Kecmanovic (23) or Jiri Lehecka (21) in the last four on Saturday.
Andrey Rublev (25) secured his place in the semi-finals after recovering from a poor start to beat Bosnian wild card Damir Dzumhur (30) 7-5, 6-3.
Rublev, who won his first Masters title in Monte Carlo last week, trailed the 202nd-ranked Dzumhur 5-2 in the opening set before saving a set point and winning five games on the bounce.
The second seed was again under pressure as he fought off four break points early in the second set, but steadied himself once more and grabbed the key break in the fifth game.
"We've always had tough battles and today was the same. I was lucky I was able to come back," said Rublev, now unbeaten in five matches against Dzumhur.
Rublev's reward for extending his winning run to seven matches is a semi-final against Slovakia's Alex Molcan (25), the world number 73 who beat Laslo Djere (27) of Serbia in three sets.