The Scot had looked set to rally from the brink of defeat after defying Koepfer when the German served for the match at 5-4 in the second set.
But having reeled off two successive breaks of serve to force a decider, Murray missed his first two match points on the Koepfer serve at 5-4, before blowing five more in an 18-minute tie-break to fall 6-4 5-7 7-6 (9).
It capped an amazing shift in fortunes for Koepfer, who had been thumped 6-3 6-0 by Miomar Kecmanovic in the final round of qualifying only to earn a second chance following the withdrawal of Murray’s original opponent, Jenson Brooksby.
Koepfer looked set to take full advantage as Murray started in listless fashion, falling a double-break down before dropping the first set, then losing his serve again in the first game of the second.
But when Koepfer failed to serve out for the match it seemed the momentum had swung back towards Murray, who looked determined to advance at a tournament where his victory in 2016 sealed his rise to world number one.
If his current ambitions are more modest, Murray looked as hungry as ever as he saved three break points to hold for 4-3 before fashioning his first of many match-winning opportunities at 5-4.
This time it was Koepfer who rallied, forcing a final set tie-break in which he saved five more match point chances for Murray, the best of which with a flashing cross-court backhand to drag the breaker back level at 6-6.
In stark contrast to Murray, Koepfer would need just one chance to seal victory, a long forehand from Murray bringing an end to the drama and sending the exasperated Scot out of the tournament.
Earlier, Cameron Norrie kept alive his hopes of qualifying for the ATP Finals with a dominant victory over Federico Delbonis.
The British number one suffered a painful loss to Felix Auger-Aliassime in Vienna last week having held match points but began strongly in the French capital, winning nine games in a row in a 6-2 6-1 victory over Argentinian Delbonis.
It was Norrie’s 100th tour-level win, 49 of which have come this year.
The 26-year-old told Amazon Prime Video: “I know the score looked fairly comfortable but there were a lot of tough games in there. I felt I played a pretty complete match and really enjoyed my tennis again. It was far from easy but I was happy with my performance.”
Norrie sits 11th in the race to qualify for the eight-man season-ending tournament in Turin and needs to make up 140 points on Italian Jannik Sinner over the next two weeks.
“It’s pretty cool just to be in the race for that and to be playing these matches with a little added pressure and a little added motivation,” said Norrie, who hit another career-high ranking of 13th on Monday.
“You’re kind of watching what everyone else is doing and I think it’s pretty interesting and it’s exactly where I want to be and the matches I want to be playing.”
In the second round he will face either American Reilly Opelka or Serbia’s Filip Krajinovic.
But compatriot Dan Evans failed to join Norrie in the second round as he fell to a 2-6 7-5 7-5 defeat to Kazakhstan’s Alexander Bublik.
Evans dominated the opening set but allowed his opponent to level the match with a crucial break in the second to set up a tight decider.
Bublik broke the Briton at 4-4 but was broken back when he served for the match, with Evans saving a match point and converting his fourth break point.
Just when the momentum seemed to have shifted back in Evans’ direction, he was promptly broken again and Bublik made no mistake second time around to seal his place in the next round.