MELBOURNE, Australia — Serena Williams was only thinking out loud when she muttered that this Australian Open had been ‘‘the worst two weeks.’’
Not long after a courtside microphone picked up those comments during her quarterfinal with 19-year-old American Sloane Stephens, things got a whole lot worse.
Stephens outplayed Williams, whose movement and serves had been slowed by a back injury, and beat the 15-time Grand Slam champion 3-6, 7-5, 6-4. It was Williams’ first loss since Aug. 17, and her first defeat at a Grand Slam tournament since last year’s French Open.
Four-time Australian Open winner Roger Federer, a 17-time Grand Slam champion, looked for a while like he might join Williams on the sidelines. But Federer eked out a 7-6 (4), 4-6, 7-6 (4), 3-6, 6-3 win over 2008 finalist Jo-Wilfried Tsonga in a match that lasted 3 hours, 34 minutes.
Federer, who broke Tsonga in the fourth game of the deciding set, converted his fifth match point while serving after Tsonga saved four match points in the previous game. Federer, who advanced to the semifinals for the 10th consecutive year at Melbourne Park, will play U.S. Open champion Andy Murray on Friday.
‘‘I thought he played very aggressive,’’ Federer said of Tsonga. ‘‘I love those four-set or five-set thrillers and I was part of one tonight.’’
Murray advanced earlier Wednesday with a 6-4, 6-1, 6-2 victory over Jeremy Chardy. The other men’s semifinal has defending champion Novak Djokovic playing David Ferrer on Thursday
Williams’ downer of a Grand Slam Down Under started badly when she turned her right ankle in her opening match at Melbourne Park.
‘‘I’ve had a tough two weeks between the ankle ... and my back, which started hurting,’’ Williams said. ‘‘A lot of stuff.’’
While Williams packed for home — she and sister Venus have also lost in doubles — Stephens advanced to a semifinal Thursday against defending champion Victoria Azarenka.
The top-seeded Azarenka beat Svetlana Kuznetsova 7-5, 6-1 in the early quarterfinal at Rod Laver Arena. Maria Sharapova, who has lost only nine games in five matches, plays Li Na in the other semifinal Thursday.
Williams hurt her back in the eighth game of the second set and things got progressively worse. She yelled at herself on several occasions, and smashed a racket into the court, earning a $1,500 fine from tournament officials.
‘‘I was running to the net for a drop shot,’’ Williams said, describing the lead up to her injury. ‘‘As I went to hit it, it was on the backhand. I even screamed on the court. I totally locked up after that.’’
She reiterated after the match that her injuries had made this Australian Open difficult for her.
‘‘Absolutely, I’m almost relieved that it’s over because there’s only so much I felt I could do,’’ she said. ‘‘I’ve been thrown a lot of (curve) balls these two weeks.’’
Stephens has been, too, but has coped well, and the magnitude of her accomplishment only hit her while she was warming down after the match.
‘‘I was stretching, and I was like, ‘I’m in the semis of a Grand Slam.’ I was like, ‘Whoa. It wasn’t as hard as I thought,’’’ she said. ‘‘To be in the semis of a Grand Slam is definitely a good accomplishment. A lot of hard work.’’
The No. 29-seeded Stephens hadn’t been given much of a chance of beating Williams, who lost only four matches in 2012 and was in contention to regain the No. 1 ranking at the age of 31.
Williams’ latest winning streak included a straight-set win over Stephens at the Brisbane International this month.
Stephens wasn’t even sure that she could beat Williams until she woke up Wednesday.
‘‘When I got up, I was like, ‘Look, Dude, like, you can do this.’ Like, ‘Go out and play and do your best,’’ she said.
Williams walked around the net to congratulate Stephens, who then clapped her hand on her racket and waved to the crowd, a look of disbelief on her face.
Stephens has said she had a photo of Williams in her room when she was a child, and had long admired the Williams sisters.
‘‘This is so crazy. Oh my goodness,’’ Stephens said, wiping away tears in her post-match TV interview. ‘‘I think I’ll put a poster of myself (up) now.’’
Azarenka, with her most famous fan sitting in the crowd wearing a shirt reminding her to keep calm, overcame some early jitters to beat Kuznetsova.
After dropping serve in a long fourth game that went to deuce 10 times, Azarenka recovered to dominate the rest of the match against Kuznetsova, a two-time major winner who was floating dangerously in the draw with a No. 75 ranking as she recovers from a knee injury.
Azarenka’s American rapper friend, Redfoo, returned from a concert in Malaysia to attend Wednesday’s quarterfinal match.
Wearing a red sleeveless T-shirt that read ‘‘Keep Calm and Bring Out the Bottles,’’ the name of his next single, Redfoo stood, clapped and yelled ‘‘Come on, Vika!’’ during the tight first set.
Williams’ loss was a boost for Azarenka, who lost all five head-to-heads against the American in 2012 and is 1-11 in their career meetings.
The 25-year-old Murray had his service broken for only the second time while serving for the match. But he broke back immediately to clinch a quarterfinal victory.
Murray discounted comments in the British media that he was upset with an almost full schedule of day matches while Federer was given featured cooler night slots on Rod Laver Arena.
‘‘The scheduling for me is part and parcel of playing in really any tennis tournament,’’ Murray said. ‘‘It’s tough to make the schedule perfect for every single player.’’