MELBOURNE, Australia — Roger Federer ambled to the net, slowly shaking his head. He let out a deep sigh.

The defending champion had escaped, and he knew it after five demanding sets. It was that kind of day at the Australian Open for Venus Williams, too. Her escape, however, came with screaming, wincing pain.

Williams injured a muscle between her stomach and groin Wednesday as she twisted for a volley. She needed a medical timeout after losing the first set. She was on the verge of tears, and apparently elimination. But she refused to stop playing, something she has never done in a Grand Slam match.

The seven-time Grand Slam winner rallied to take the next two sets and defeat Sandra Zahlavova of the Czech Republic 6-7 (6), 6-0, 6-4.

Federer faced a more familiar problem — Gilles Simon. He’s one of only three men on the tour with a winning record against the Swiss great. Federer raced to a two-set lead in a second-round night match, and seemed in the clear. He had never while lost so far ahead in a Grand Slam tournament.

Then Simon, who beat Federer twice in 2008 on hard courts in their only two previous encounters, started to take more risks, moving the 16-time Grand Slam champion out of his comfort zone. But Federer persevered, finishing off a 6-2, 6-3, 4-6, 4-6, 6-3 victory on his fifth match point.

“I’m happy I survived a scare like today. It’s not the first time … it does happen,” he said. “You just try to stay calm even though I’m not playing for much. He’s playing for the huge upset, and I’m just trying to get through.But, look, I handled it well tonight, and I’m very happy that things turned out so nicely at the end.”

In the third set, Federer’s reliable forehand started to falter. In the fourth, the shots that usually touch the lines were missing. The shoulders started slouching. Simon is no pushover — he has beaten Rafael Nadal and Novak Djokovic and been ranked as high as No. 6.

“Well, I’m stressing out at this point, obviously,” Federer explained in an oncourt interview.

In the fifth, Federer recovered. But even when he had triple match point on Simon’s serve, he couldn’t finish it off immediately.

“I was like, ’This can’t be true, right?’” Federer said. “I’ve had some tough losses last year. Obviously, they’re in the past and I’ve had a wonderful last six months. But sometimes it just doesn’t seem to go your way. I really had to play an extremely good game to close it out. Obviously, I was quite relieved. “

It’s been 31 major tournaments, dating to the 2003 French Open, since Federer failed to reach the third round at a Grand Slam.

“Look, at the end of the day I’m happy I’m through,” he said at a news conference. “That’s what it comes down to. Doesn’t matter if you win in straight or in five. Just keep on moving on in the draw and give yourself an opportunity … stay alive and feel good.”

Simon’s ranking has dropped because he was off the tour with a knee problem for long stretches last year, but he came into the Open after winning the tuneup event in Sydney. His ranking is now in the 30s, but without a seeding the draw worked against him.

“I’m just sad that I had to play Roger this soon in the tournament,” he said. “Even with a very good match from me, it was not enough. Of course, it’s good to play this kind of match. The problem is I lost second round, and tomorrow you will forget it and I will have to work for the next tournament.”

The only other two active players with winning records against Federer play in the second round Thursday — Rafael Nadal and Andy Murray.

The top-ranked Nadal will be aiming for his 23rd consecutive victory in Grand Slam play when he faces American qualifier Ryan Sweeting. The muscular Spaniard is bidding for a “Rafa Slam” — holding all four majors at once.

Murray, ranked No. 5 and the losing finalist last year, plays Illya Marchenko of Ukraine in a night match on Margaret Court Arena.

On the women’s side, No. 3-ranked Kim Clijsters takes on Carla Suarez Navarro to start play on center court.

Djokovic knows what it takes to beat Federer at Melbourne Park. He did that in the semifinals in 2008 en route to the Australian title. He moved into the third round relatively comfortably with a 7-5, 6-7 (8), 6-0, 6-2 over Croatia’s Ivan Dodig.

After the scores were locked at one set apiece, the No. 3-ranked Serb won 12 of the next 14 games to put it behind doubt. Djokovic will next play his Serbian Davis Cup teammate Viktor Troicki, who beat Frenchman Nicolas Mahut 6-4, 6-2, 1-6, 6-3.

The pair could meet in the quarterfinals. Henin will have to get past two-time major winner Svetlana Kuznetsova just to survive the third round. The No. 23-seeded Kuznetsova beat Dutch qualifier Arantxa Rus 6-1, 6-4.

With defending champion Serena Williams sidelined because of an injured foot, the women’s draw is wide open. And clearly among the contenders is sister Venus Williams.

Williams, seeded fourth, is confident she’ll have recovered from her injury, acknowledging that in a tense match things can get a “bit hysterical.”

Until the injury, the talk surrounding Williams was of her flesh-colored “nude pants” and “illusion” dress that, as she promised, shows more “skin” than ever. She said the lattice-style blouse and satin skirt ensemble was inspired by “Alice in Wonderland” and an unexpected tumble into fantasy land.

“Don’t laugh,” she said. “But it’s kind of about a surprise. This outfit is about having a surprise in tennis … so it’s called the ’Wonderland dress.’ I put a lot of thought into my dresses. I love fantasy, and this was kind of a way to express who I am on the court.”