Updated

By Alastair Himmer

MELBOURNE (Reuters) - Roger Federer flirted with danger before squeaking past unseeded nemesis Gilles Simon 6-2 6-3 4-6 4-6 6-3 to reach the third round of the Australian Open on Wednesday.

Federer had lost both his previous two meetings against Simon, but the 16-times grand slam winner had the measure of the Frenchman on a chilly night in Melbourne -- just.

"Today I got lucky. But it's all about staying alive and moving on," defending champion Federer told reporters.

"I was stressing out (at two sets all) but I thought I played great. I didn't panic and I got through. I handled it well.

"I really enjoyed myself tonight," the second seed added, perhaps a little untruthfully after twanging 53 unforced errors, many of them horribly shanked forehands.

"The fifth set you threw tactics out of the door, because all you want to do is just fight and find an extra gear, which I was able to find."

Federer caught fire early, the Swiss master ripping a forehand down the line to break in the third game and dictate the tone for the first two sets.

ONE-WAY TRAFFIC

With a tormented Simon stalking along the baseline between points cursing his misfortune, it looked all but over after 68 minutes of one-way traffic.

But Simon, who won in Sydney in the run-up to the year's first grand slam, bravely clawed his way back onto level terms as Federer's magic suddenly deserted him.

Federer, tension etched all over his face, demonstrated nerves of steel, however, just when it looked as though Superman had left the building.

The 29-year-old, who holds an astonishing 165-0 record after winning the first two sets, threaded a forehand down the line to break for 4-2 in the fifth set.

With wife Mirka barely able to watch after he frittered away four match points, Federer finally ended a tortuous three hours and 14 minutes by drilling an 11th ace deep into the corner.

"I'm just sad that I had to play Roger this soon in the tournament," said a dejected Simon, who rose as high as sixth in the world in 2009. "I had to hit everything and take risks.

"The problem is I lost second round. Tomorrow you will forget it and I will have to work for the next tournament."

(Editing by Kevin Fylan and Pritha Sarkar)