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.