Dan Evans' bid to win his second ATP title was dashed as Spain's Roberto Carballes Baena came from a set down to reach the Grand Prix Hassan II final.
The British number two, 32, looked on course for his fourth ATP final when he won the first set in Marrakech.
The second set went with serve before Baena, 30, broke the second seed to make it 5-4 and then level the score.
Baena, ranked 82nd in the world, then broke the world number 30 twice in the decider to win 2-6 6-4 6-2.
The Spaniard upset fourth seed Tallon Griekspoor in the quarter-finals to leave Evans as the only seed to reach the last four.
Before travelling to Morocco, Evans had been on a six-match losing streak since winning in the second round of the Australian Open in January.
The Briton's only ATP title came at Melbourne's Murray River Open in February 2021 and his other two finals also came on the 250 Series.
Baena, who won the 2018 Ecuador Open in his only previous ATP final, will now play Alexandre Muller of France or Russia's Pavel Kotov, both ranked outside the world's top 100.