Williams' victory, her fourth tournament success of 2013 and only the seventh on clay since she turned pro in 1995, prevented Sharapova from leapfrogging her to the top of the rankings.
It also showed the 31-year-old American, a 15-times grand slam singles champion, is on red-hot form as she prepares her bid to add to her sole French Open title at Roland Garros starting later this month.
With the sliding roof over the Manolo Santana show court open to a cloudless sky, Sharapova struggled to find her range as Williams battered winners to all corners to race into a one-set lead.
The Russian world number two mounted a fightback at the start of the second set but could not sustain it and Williams broke her for a fifth time in the match to secure a first title on red clay - the Madrid courts were blue last year - since the 2002 French Open.
"It's not the ultimate title, but it's a good start in the right direction," Williams, who was upset by Virginie Razzano in the first round at Roland Garros last year, told a news conference.
"I don't know how many more (titles) I can win," she added.
"Like I say every day, who knows if I'll ever win another title? I just want to live the moment and the dream every chance I get."
Sharapova, 26, the French Open champion, has a woeful record against Williams. She has only beaten her twice in 15 attempts, and never on clay, with both victories coming almost a decade ago.
She did not seem too dejected by her latest reverse to the American and said she was pleased with the way her preparations for Roland Garros were going.
"At the end of the day I'm setting myself up opportunities to go out on the court and face her and play against her," Sharapova told a news conference.
"Obviously I wouldn't be happy if I wouldn't set up those opportunities because I do want to go on the court and I do want to face someone that's number one in the world and is playing tennis the way she does," she added.
"So I am happy about the fact of getting late into tournaments, winning tournaments, getting to the finals.
"If that means having to face Serena in the final that's a pretty great challenge out there. I take it, because I'm a very big competitor."
Williams, the oldest player to hold the number one ranking, is 10th on the all-time list for most career titles.
Martina Navratilova leads on 167, followed by Chris Evert with 154 and Steffi Graf with 107. Sharapova has 29, third among active players behind Serena and her sister Venus Williams who has 44.
- Sports & Recreation
- Venus Williams