Guillaume Martin won the Tour de l'Ain but only after a thrilling Stage 3 saw Antonio Pedrero solo to victory.