WATCH the Miami Open LIVE & ONLY on beIN SPORTS | available via Foxtel, Kayo Sports, Fetch TV & beIN SPORTS CONNECT
Diyas advanced to a second round meeting with Swiss 11th seed Belinda Bencic after completing a 6-2, 7-6 (12/10) victory in 1hr 28min on the Hard Rock Stadium's Grandstand court.
The round of 128 defeat is the 40-year-old Williams' earliest exit in Miami since she made her debut in the tournament in 1997.
After Diyas raced through the first set, Williams fought back in the second, breaking her Kazakh opponent's serve in the 12th game to force a tie break.
Williams saved three match points to extend the tie break but handed Diyas a fourth match point with a double fault which she converted to complete victory.
"I'm very happy with the win, especially against such a legend as Venus -- I looked up to her when I was little," the 27-year-old from Almaty said.
Diyas set up the victory behind an accurate service game, winning 61 percent of her first serve points, and varying play cleverly to pull Williams around the court.
Tuesday marked the start of main draw action at this year's tournament, which is being held after the Covid-19 pandemic wiped out the 2020 event.
A slew of top names have withdrawn from Miami in the build-up, with Roger Federer, Rafael Nadal and Novak Djokovic all pulling out of the men's draw.
Britain's Andy Murray became the latest star to withdraw earlier Tuesday after suffering a groin injury.
Former world number one Serena Williams meanwhile pulled out of the women's tournament on Sunday.