Graf, won the last 10 games in adding to a trophy haul that included crowns in 2002, 2003, 2004, 2007 and 2008 and runner-up efforts in 1999 and 2009.
Serena Williams wins the women's final of the Sony Open tennis tournament in Key Biscayne, Florida. (Reuters)
"It's so good to win number six," Williams said.
It was the 11th match victory in a row for Williams over Sharapova, coming in their first meeting as the top two players in the world rankings, and gave the 31-year-old American a 12-2 edge in their all-time rivalry.
But Sharapova took a set off Williams for the first time since 2008 and was up a break in the second set before the reigning Olympic, Wimbledon and US Open champion roared back and breaking the Russian in her last five service games.
"She definitely pushed me," Williams said. "I definitely look forward to our next matches. It's going to be fun for everyone."
Williams became only the fourth woman in the modern era to win the same event six times, joining Graf, Chris Evert and Martina Navratilova. Graf's husband, Andre Agassi, won the Miami men's title six times.
Williams, a 15-time Grand Slam singles champion, also became the oldest women's champion in Miami history, four months older than Evert when the legend won here in 1986 at 31 years and two months of age.
Sharapova, 25, suffered her fifth championship-match loss at Miami and still looks for her first Miami title after having been denied a 29th career WTA triumph.
The $8.5 million hardcourt event, which also includes an ATP Masters tournament, concludes Sunday with Britain's Andy Murray facing Spaniard David Ferrer in the men's final.
Four-time Grand Slam title winner Sharapova had won 11 matches in a row without dropping a set since losing to Williams in a Doha semi-final, including a title earlier this month at Indian Wells.
Sharapova missed a chance to match Graf and Kim Clijsters as the only women to win at Indian Wells and Miami in the same year.
"It has been a really nice month," Sharapova said. "I'm disappointed to end it like this but Serena played a really great match. I'm sure we will be playing a few more times this year."
Sharapova's only two victories over Williams came in 2004 in the Wimbledon final and the WTA Los Angeles final.
Williams saved three break points in the third game of the match and held. Then the two traded breaks, Williams netting a backhand to surrender the fifth game before Sharapova swatted a backhand beyond the baseline to allow Williams to equalize at 3-3.
Sharapova broke again in the ninth game, Williams denying the Russian's first chance with a 112-mph ace but following with a double fault and then netting a forehand on the run to give Sharapova a 5-4 edge.
Sharapova then held at love and claimed the first set when Williams sent a forehand long, ending a run of 13 sets in a row lost to the American since a 2008 quarter-final on clay at Charleston, South Carolina.
Williams, who made 20 unforced errors to 15 winners in the opening set, smacked her bench with her racquet during a changeover after dropping the set, then held at love to open the second set and broke Sharapova for a 2-0 edge.
Sharapova broke back at love in the third and fifth games to seize a 3-2 lead, only to have Williams break back at love in the sixth to pull even.
Williams held serve, then broke again to 5-3 when Sharapova netted a forehand and held again to force a third set.
Williams broke Sharapova to open the third set on a forehand by the Russian that was ruled just beyond the baseline after a challenge by the American.
Sharapova's fifth double fault handed over another break and Williams held for a 4-0 advantage, broke again and finished off the victory with a service winner.