Wawrinka, last year's Australian Open winner, struggled until breaking loose with his big game in the final set as he defeated Guillermo Garcia-Lopez 6-7 (2/7), 6-4, 6-2 for his second win over the Spaniard in three weeks.
Murray saved five break points to hold off determined Canadian Vasek Pospisil 6-3, 7-5 and reach the quarter-finals.
The Scottish top seed and 2009 champion will next meet eighth seed Gilles Simon after the Frenchman needed just 67 minutes for a 6-4, 6-3 defeat of Jeremy Chardy.
Murray stands an overwhelming 12-1 in the series with number 19 Simon.
Wawrinka had his problems against Garcia-Lopez, whom he beat at the Australian Open last month.
The Swiss fourth seed went down badly in an opening-set tiebreaker to end a 63-minute opening set before recovering to start getting the match under control.
Wawrinka won the second set and ran away with the third to stay alive in an event he last played a decade ago.
"It was a good match with a lot of intensity," said Wawrinka.
"It was a tough battle," the Lausanne native said.
"Ï'm happy with how I'm playing, generally I'm feeling good here," he said.
"The first two sets were very intense, but I was playing a bit passive."
After the second set, Wawrink said, "I increased my aggression and relaxed a bit and started playing better."
Murray battled for one and three-quarter hours against the 59th-ranked Pospisil to defeat the Canadian for a second time.
Murray finally prevailed with a break of his opponent for 6-5 in the final set, earning the win in the next game when Pospisil's return was ruled wide.
"It was a tough match physically and mentally," said Murray, who lost the Australian Open final to Novak Djokovic less than a fortnight ago.
"Vasek is a good athlete and gets to a lot of balls," Murray said.
"Thanks to this slow court, I was able to move him around at the end and control the points," he said.
"We had some long games and tough points, it was difficult."
Murray is wary of playing Simon, whom he last beat in Acapulco in 2014.
"Gilles is a great mover and retriever," he said.
"He's got excellent timing, so of course I'm expecting a difficult challenge."
Third-seeded holder Tomas Berdych reached the last eight at the Ahoy Stadium with a defeat of Italian Andreas Seppi 6-0, 3-6, 6-3.
Berdych swept the opening set before being made to work in the second as Seppi levelled.
The Czech finally prevailed thanks to a break midway through the final set, running out the winner on his first match point.
"Andreas played very well in the second set. For me it was about trying to play like I had in the first set," said Berdych.
"I was still able to finally win in the end."
Simon improved to 3-0 over Chardy after beating his compatriot at Roland Garros in 2011 and the Madrid Masters in 2013.
Simon, holder of 11 career titles, finished his modest effort with nine winners and broke Chardy twice in the second set.
The winner never faced a break point.