MELBOURNE, Australia -- Three times in the first four sets, David Ferrer faced the prospect of being ousted of the Australian Open by a fellow Spaniard who'd never beaten him in a dozen competitive matches.

The No. 4-seeded Ferrer survived once in the third set and twice in the fourth when No. 10 Nicolas Almagro was serving for the match, but held firm and finally advanced to his fourth semifinal in six Grand Slam events with a 4-6, 4-6, 7-5, 7-6 (4), 6-2 win on Tuesday.  
"It was (a) miracle I won this match, I think," Ferrer said. "I tried to fight every point, that's my game. I always to fight."  
Almagro dominated the first two sets and was serving for the match in the third when Ferrer bounced back, breaking in the crucial 10th game and then breaking his Davis Cup teammate again.  
The fourth set featured eight service breaks, and Ferrer finally took control in a tiebreaker to force a fifth set.  
Almagro has played 33 consecutive majors, but never reached a semifinal. This was his first Grand Slam quarterfinal on any surface other than clay -- he reached three quarterfinals at the French -- and he really took the match to Ferrer, the leading Spaniard in the tournament with the absence of 11-time major winner Rafael Nadal.  
Almagro hurt his upper left leg late in the fourth set and needed a medical timeout before the fifth. After holding serve in a long game to open the fifth set, he quickly wilted after the first break.  
On the last point, he hit a service return back into play and had already started strolling to the net as Ferrer prepared to hit the winner.  
As he left the court, he gave his compatriot a friendly pat on the back as Ferrer packed his bag on the courtside chairs, then left Rod Laver Arena.  
"In the important moments, I played more consistent in my game," he said. "Of course, in the next round, the semifinals, I need to play my best tennis, better than today."  
He will next play either Novak Djokovic, who is bidding for a third consecutive Australian title -- unprecedented in the Open era -- or No. 5 Tomas Berdych. Ferrer has played four semifinals in Grand Slams and lost them all.  
Li Na had an easier time as the first woman moving to the semifinals.  
The sixth-seeded Li advanced to her third Australian Open semifinals in four years with a 7-5, 6-3 win over Agnieszka Radwanska, which ended the Polish player's 13-match winning streak.  
"She's a tough player. I was feeling today against a wall," said Li, who lost the 2011 Australian Open final to Kim Clijsters only months before her Grand Slam breakthrough at the French Open.  
"She can hit everywhere, but without a mistake. I was feeling just very tough. You have to focus on every shot. Not every point, every shot."  
Li will play the winner of Tuesday's later all-Russian quarterfinal between No. 2-ranked Maria Sharapova, who conceded only five games in her first four matches at Melbourne Park, and Ekaterina Makarova.  
"At least now I'm in the semis," Li said. Sharapova, "has to play, so... Right? Now I can start now to enjoy my day. She has to fight, yeah. So that's better."  
The quarterfinals on the other half of the draw will feature American teenager Sloane Stephens against Serena Williams, who is aiming for a third consecutive major title, and defending champion Victoria Azarenka against two-time major winner Svetlana Kuznetsova.  
Stephens has heard a lot of advice from Serena Williams. Pointers on her groundstrokes, and even on her grunts.  
It's been mostly gentle encouragement, occasionally spiced with headline-making comments from Williams, who has predicted the 19-year-old American will one day top the women's rankings.  
As Stephens learned earlier this month, though, it's one thing to play with Williams, another to play against the 15-time Grand Slam champion.  
With a comeback 6-1, 3-6, 7-5 win over Bojana Jovanovski on Monday, Stephens qualified for her first quarterfinal at a major tournament. Williams has already played at that level 34 times.  
"It will be tough, obviously. It's quarters of a Grand Slam," Stephens said. "There won't be that, like, first time, `Oh, my God, I'm playing Serena.' That's kind of out of the window now. So that's good."  
Williams and defending champion Victoria Azarenka advanced Monday, losing just four games between them against Russian rivals. Williams beat No. 14 Maria Kirilenko 6-2, 6-0, and Azarenka defeated Elena Vesnina 6-1, 6-1.  
On the men's side, No. 2 Roger Federer and U.S. Open champion Andy Murray stayed on course for a semifinal in their half of the draw.  
Federer won 6-4, 7-6 (4), 6-2 over big-serving Canadian Milos Raonic, advancing to the quarterfinals at a Grand Slam for the 35th consecutive time, while Murray took advantage of Gilles Simon's fatigue for a 6-3, 6-1, 6-3 victory.  
Federer will face 2008 Australian finalist Jo-Wilfried Tsonga, who beat friend and fellow Frenchman Richard Gasquet 6-4, 3-6, 6-3, 6-2.  
Murray, who ended a 76-year drought for British men in Grand Slam tournaments with a win at the U.S. Open, will next play unseeded Frenchman Jeremy Chardy.