Raonic, the No. 8 seed from Thornhill, Ont., trailed 2-5 in the opening set when he retired from his second-round match against Argentina's Juan Monaco. It wasn't immediately clear why Raonic decided to end the match.
The unseeded Pospisil, from Vancouver, dropped a 7-6 (1), 3-6, 6-4 decision to No. 14 Roberto Bautista Agut despite firing 15 aces to the Spaniard's two.
Federer saved five match points and rallied from a 5-2 deficit in the third-set tiebreaker before finally beating Leonardo Mayer 7-5, 3-6, 7-6 (7) in a thrilling second-round match.
Rafael Nadal, meanwhile, lost to fellow Spaniard Feliciano Lopez 6-3, 7-6 (6) only days after appendicitis left him bedridden and uncertain if he'd be able to compete.
Federer hadn't played since helping Switzerland beat Italy to make the Davis Cup final a month ago, and the inactivity showed. He made an uncharacteristic 57 unforced errors — including some bad mishits — and only won about half of his points at the net.
The Swiss star was also a little fortunate. On Mayer's first match point at 5-4 in the third, the Argentine aimed a backhand passing shot down the line but the ball clipped the tape and fell back on his side of the net.
Federer finally put it away on his first match point with a backhand lob that just caught the line.
"I think I got unbelievably lucky today. Let's be quite honest. I think he deserved it," Federer said. "Could be my greatest escape thus far."
As for the reason for his difficulties, the 17-time Grand Slam title winner pointed to his spell away from the tour.
"Midway through the third set I was like, yeah, I have been on vacation actually, so it's normal that I'm struggling," he said. "I was trying to go for an all-time record of missed volleys tonight."
Nadal was in so much pain from appendicitis earlier this week, he couldn't sleep, eat or even get out of bed for several days.
After an aggressive course of antibiotics to control the inflammation, he felt healthy enough to play his opening match against Lopez. However, his shots lacked depth and power, and his serve didn't have its usual punch.
Nadal said he felt a little dizzy from the antibiotics, but otherwise wasn't in a great deal of pain.
"Even today the doctors told me that I was very, very lucky that I did not have to go for surgery straight, can (treat) with antibiotics," he said. "Pain I think is under control. That's important. I think I was lucky for that."
The 14-time major winner had just returned to the tour after two months on the sidelines with a wrist injury. Now he faces likely surgery to have his appendix removed, which could keep him out of the ATP Tour Finals in London next month.
"My answer today honestly is I'm going to do it after the World Tour Finals. You never know. Depends how the things improve," he said. "When you are on the bed for three days, the only thing you want to do is feel better, feel healthy again, and that's it."
Murray and Djokovic also moved into the third round with wins.
Murray has been on a roll over the last three weeks in China, winning nine of his last 10 matches as he tries to qualify for the ATP Finals. He defeated Jerzy Janowicz of Poland 7-5, 6-2.
He next faces David Ferrer, another player fighting for a spot in the elite eight-man field. Ferrer rallied to beat Martin Klizan 4-6, 7-6 (4), 6-4.
"I haven't been in this position for a while, so in some ways it's kind of new," Murray said of the fight to qualify for London. "But I'm enjoying it so far. Just giving me a little bit of extra focus and direction for the last few tournaments."
With Chinese basketball star Yao Ming in the stands, Djokovic extended his unbeaten streak in China to 26 straight matches with a 6-3, 6-4 win over Dominic Thiem of Austria, at 21, the youngest player in the top 50.
Djokovic had never played Thiem before and he was impressed by the Austrian's power game.
"I had to be on alert from the start because he was serving already 215 kilometres per hour (133 mph) in the first service games," he said. "He was going for it. I don't blame him. He's a young player, playing on centre court, it's his opportunity to shine."
Kei Nishikori and Stan Wawrinka were among a number of seeds to be knocked out.
The fourth-seeded Wawrinka lost early for the second straight week, squandering a 3-0 lead in the final set before falling to Gilles Simon 5-7, 7-5, 6-4. He lost to 103rd-ranked Tatsuma Ito in the first round of the Japan Open last week.
Wawrinka said he's struggled to maintain his focus since his breakthrough win at the Australian Open, causing the early losses to pile up.
"It's been an amazing year, but really tough, also," he said. "It's not easy to stay at the top. You really have to find your way."
For Nishikori, a dominant stretch of tennis finally caught up with him. Coming off back-to-back titles in Kuala Lumpur and Tokyo, the Japanese star was bothered by pain in his hip and back in his match against big-serving American Jack Sock, losing 7-6 (5), 6-4.
Other winners include Tomas Berdych, Julien Benneteau and John Isner.
With files from The Canadian Press.Suggest a correction