Meanwhile, China's Zheng Saisai, who underwent knee surgery after the U.S. Open previous year, lost her first Grand Slam match after making her comeback from injury to Russia's doubles specialist Ekaterina Makarova 6-4, 6-1.
Ostapenko had 48 unforced errors during the match, 13 double faults, with just 22 winners. "I mostly tried to have fun", said Kozlova after his feat.
Elina Svitolina of the Ukraine, one of the title favorites after retaining her Rome crown the week before Roland Garros, came back from a set point down to beat the unseeded Australian Alja Tomljanovic, 7-5, 6-3.
Something even more unusual happened at Roland Garros, too: Venus Williams was beaten in her opening match at a second consecutive major, the only time in her lengthy, distinguished career she's had such early back-to-back exits.
"At the moment, I'm not playing at the level I wish to, but at the same time, I understand that it is the process that obviously takes time", said Djokovic, whose seeding of No. 20 is his lowest at a Slam in 12 years.
But she gained revenge in spectacular style with a first victory over the seven-time grand slam victor for the biggest win of her career.
By losing, Ostapenko joins a ignominious group including, as well as Myskina, Steffi Graf, Jennifer Capriati, Svetlana Kuznetsova and Angelique Kerber who all lost as Grand Slam champions on the first run of their defences.
The 31-year-old has slipped down the rankings after a succession of injuries and has been handed a potentially tricky first-round clash on Suzanne Lenglen against 19-year-old wildcard Elliot Benchetrit, who is ranked just outside the world's top 300.
Ostapenko, afterward admitted she was not at the races.
"I mean, you guys make it sound like we think about it, really".
It was however supposed to be a celebration for the 37-year-old, who in her 21st appearance at Roland Garros, was playing her 100th match but the Chinese underdog had other ideas.
Ostapenko's reign ended in the first round from an unexpected defeat by Kateryna Kozlova 7-5 6-3. "We try to play our best".
"I'm happy when I see players that I've shared courts, practice, matches from juniors". "So it was really, really enjoyable for me".
Britain's Jo Konta, a Wimbledon semi-finalist past year, was beaten in straight sets by Yulia Putintseva of Kazakhstan. "But obviously I'm learning something new, and, yeah, that's the case", said Djokovic, who hasn't won a Grand Slam title since claiming his fourth in a row at the 2016 French Open.