Williams and Azarenka, both former world No. 1s, are working their way back to high-level tennis following injuries and illness. Williams, who is 4-0 against the Belarusian, appears slightly ahead in her development.
After the 10th-ranked Azarenka, who celebrated her 25th birthday, saved three match points to tie it 6-6, Williams won the first five points in the tiebreaker.
Azarenka's second serve was the biggest difference between the hard-hitting players. She won just 32 percent of her second serves, handing Williams a significant advantage.
"We both had good points," 2010 champion Azarenka said. "Venus was a little better on her execution on important points. I have to be realistic and look at the things that have to be done. It's not easy being patient but if I wanted easy, I'd go sit on a couch."
Despite losing, Azarenka was glad to be playing tennis on her birthday.
"Losing is never satisfying," she said. "But I left the best part of my day on the court. I was able to do something I love on my birthday."
Williams, who reached her third quarterfinal of the season, will face eighth-seeded Andrea Petkovic on Friday.
Williams, in her 12th career appearance at Stanford, reached her 10th quarterfinal. She has won twice and finished second five times.
Fifth-seeded Ana Ivanovic also advanced, beating Canadian qualifier Carol Zhao 6-1, 6-1.
The 11th-ranked Serb, looking for her fourth title of the year, will face top-ranked Serena Williams on Friday.
"It will be a good test to see where I need to work," Ivanovic said. "It's a different part of the season and a different kind of tournament."
Ivanovic will move into the top 10 next week for the first time in five years.
"I can't think too much about the future," Ivanovic said. "I am looking to turn it around at the U.S. Open. After the match today I went back out on the court to get the rhythm back on my serve. That's what I need to be doing."
Also, third-seeded Angelique Kerber of Germany beat Coco Vandeweghe of the U.S. 7-6 (4), 0-6, 6-2, and Garbine Muguruza of Spain topped Daniela Hantuchova of Slovakia 6-4, 6-4.