As race leader Elia Viviani (Liquigas) fell off on the first climb, defending champ Tony Martin attacked on the last climb to win the stage and claim the GC lead.