Rybarikova, seeded eighth, overcame the former world number one 7-6 (7/3), 6-4 in one hour, 53 minutes to level her head-to-head record with Sharapova at one all.
Sharapova was appearing in front of her home fans just 48 hours after claiming the Tianjin Open, her first title since returning in April from a 15-month doping ban.
The Kremlin Cup was the world number 57’s eighth wildcard invitation since testing positive for the banned substance meldonium in early 2016.
“I fought hard today as I really wanted to show my best in Moscow after a 10-year break,” the 30-year-old said.
“If it hadn’t been the Kremlin Cup I probably wouldn’t have come to play in any other event after playing five matches in five days in China.
“Physically I felt I was well but it seems that it wasn’t enough to win today.
“She (Rybarikova) played really intelligent tennis. She played skilfully, running for every single ball.”
The pair traded breaks late in the opening set, which Bratislava resident Rybarikova took in a tiebreak after one hour, seven minutes on court.
The second set was almost a carbon copy of the first, with Rybarikova breaking in the 10th game to take the set and the match.
“It was very difficult for me, because it felt like the Fed Cup. It’s absolutely normal, Maria is a huge superstar here and she’s a real champion,” said Rybarikova, who is seeking her fifth career WTA title this week.
“I’m happy that I went through this match, and it’s good for my confidence. I’m very happy with that,” she added.