The fourth-seeded Muguruza, a 22-year-old from Spain, used her big groundstrokes to keep No. 1 Williams off-balance and overcame signs of nerves in the form of nine double-faults to pull off the surprise.
Muguruza also managed to deal with Williams' dangerous serve, breaking three consecutive times from late in the first set to early in the second.
This was Muguruza's second major final; she lost to Williams at Wimbledon last year. But Muguruza has won her past two matches against Williams on the clay of Roland Garros, including in the second round in 2014.
For Williams, whose timing was not exactly right much of the afternoon, Saturday's loss delayed yet again her pursuit of matching Steffi Graf with 22 Grand Slam singles championships, the most in the Open era, which began in 1968. Margaret Court holds the all-time record of 24.
Williams got No. 21 at Wimbledon in 2015, her fourth major title in a row. But since then, she has been beaten in the semifinals at the U.S. Open by Roberta Vinci last September, in the final at the Australian Open by Angelique Kerber in January, and now by Muguruza. This is the first time in Williams' career she has lost back-to-back Grand Slam finals.
This year's visit to Paris hardly could have started off more inauspiciously for Muguruza: She lost the very first set she played in the tournament, against 38th-ranked Anna Karolina Schmiedlova.
But, oh, how Muguruza turned things around from there. She won the next 14 sets she played, displaying the deep groundstrokes and take-the-ball-early aggressiveness that flustered Williams.
The final began under a slate ceiling of clouds, but at least there was none of the heavy rain that led to flooding in Paris and a temporary shutdown of the Louvre museum. All those showers jumbled the tournament schedule, forcing Williams to be in action for a fourth straight day in the final.
Muguruza won the prematch coin toss and let Williams serve first, a fascinating choice given that Williams is widely regarded as the best server in the women's game, perhaps ever. And the decision seemed only more dubious as Muguruza managed to put the ball on play on only one of the first six points Williams served. On one early point, Muguruza whiffed completely on an attempted backhand return of an 89 mph (143 kph) high-kicking second serve.
And yet, it all wound up working out. And how.
Men's doubles: Feliciano Lopez and Marc Lopez won the French Open on Saturday for their first Grand Slam doubles title, denying Bob and Mike Bryan a 17th major trophy.
The duo became the first Spanish pair to win at Roland Garros in 26 years with a 6-4, 6-7 (6), 6-3 victory over their American rivals.
The No. 15 seeds played together only once before at a major tournament and had to struggle to get to this final.
They saved six match points in their quarterfinal win over 2014 champions Julien Benneteau and Edouard Roger-Vasselin. They also went to three sets before downing defending champions Ivan Dodig and Marcelo Melo in the semifinals.
The Bryans, the most successful pairing of all time, were seeking a third title on the red clay following victories in 2003 and 2013.
"The tough thing about us is that if we don't leave with the big trophy it's devastating," Bob Bryan said. "We have high standards, and sometimes that makes it not fun, because we can't get any kind of enjoyment out of a final or semi like maybe some other players.
"You know, that's the burden that we carry. We're feeling that pain right now. We don't take any solace out of leaving with the square plate."
Feliciano Lopez sealed the Spaniards' win with an ace and both partners fell on their back in jubilation.
"You can't imagine what it means to win a Grand Slam for the first time, against the best players in the sport," Feliciano Lopez said.
Their victory also benefited Frenchman Nicolas Mahut, who will top the doubles ranking for the first time next week.
The fifth-seeded Bryans saved a match point in the tiebreaker before evening it 1-1 in sets, but their rivals returned better in the decider and converted two of three break points.
"Winning a Grand Slam is something amazing, and I didn't have a Grand Slam victory on my resume," Marc Lopez said. "Roland Garros is my favorite tournament. It has been the case for quite a long time. When I was a kid I was watching the matches of great champions, the Spanish champions."
The previous Spanish doubles team to win the French Open was Sergio Casal and Emilio Sanchez in 1990.