By Andrew Downie

RIO DE JANEIRO (Reuters) - The man who lit the Olympic flame was told he would be replacing Pele only an hour ahead of time and the selection of Vanderlei Cordeiro de Lima provided the Rio Olympics with the perfect redemption story before they had even started.

Cordeiro was leading the Olympic marathon in Athens in 2004 when a crazed fan tried to haul him to the ground. Spectators pulled the man off and Cordeiro went on to win the bronze medal.

But if that attack was unexpected, the call from organizers at the Maracana stadium on Friday was no less so after former Brazil striker Pele, arguably the greatest footballer of all time, had pulled out due to ill-health.

"It was about an hour before it happened, I was already in the stadium," Lima told Brazil's Lance newspaper after stopping to grab a beer at a petrol station outside the stadium.

"I wasn't expecting it. I know that when they did polls there were a lot of appeals for Vanderlei to light the cauldron. I gave interviews to Brazilian and foreign media, they had raised the idea abroad, but I never thought it was a possibility. I never thought I could be that person."

Cordeiro's late selection was welcomed by fans.

"Pele is our greatest sportsman but he never played in an Olympics," Vania de Araujo said on Twitter. "The choice of Vanderlei was perfect. He wasn't famous, but he was committed."

Vanderlei said his unforgettable Friday night in Rio would now replace the bittersweet memory of the race in Athens.

"Man, they called me at the last minute to replace Pele." he said. "Living this emotional experience was better than winning a medal. I was able to share this with the whole nation, I was representing every one of them."

(Reporting by Andrew Downie, editing by Ed Osmond)