Less than two years ago, the man poised to become Spain's new prime minister was staring at the premature end of an unremarkable political career.

The heavyweights of Spain's Socialists had forced Pedro Sanchez' removal as their leader. Back-to-back losses by the party in general elections had left Sanchez without credit and he was ostracized after a rebellion from within his own ranks.

Fast forward to Friday: Sanchez is set to become the leader of the eurozone's fourth leading economy after completing an audacious bid to oust conservative Prime Minister Mariano Rajoy from power in a no-confidence vote.

Sanchez completed his spectacular turnaround after seizing the opportunity provided by last week's court verdict in a massive corruption case involving Rajoy's conservative Popular Party.