The third seeds came from a set down to beat home favourites Julius Thole and Clemens Wickler 19-21, 21-17, 15-11 to claim their country's first world crown and a place at next year's Olympic Games.
A typically powerful spike from Stoyanovskiy sealed victory and made the 22-year-old the youngest world champion in beach volleyball history.
"No words needed. We are world champions and that's enough. I never dreamt about it, but maybe I believed all these years that we can win." - Oleg Stoyanovskiy
Also going to Tokyo 2020 are Canada's Sarah Pavan and Melissa Humana-Paredes who took the women's title on Saturday.
Russian first in Hamburg
Thole and Wickler surprised Norway's top seeds Anders Mol and Christian Sorum to reach the final.
In a tense first set, the home crowd went wild when Wickler changed direction superbly to keep the ball alive, and Thole's hard spike down the middle made it 18-16.
The Russians hit back to level at 19-19, but Krasilnikov hit a serve long to hand their opponents a first set point.
And a huge swerving delivery from Wickler, which Stoyanovskiy could not control, sealed the first set for the German pair 21-19.
Russia raised their service game in the second set to take a 6-2 lead.
The Germans never looked like getting back on terms as they made some costly errors on serve, and Stoyanovskiy's power at the net saw the visitors take the set 21-17 to force a decider.
Germany took a medical time out at 4-4 with Thole receiving treatment on what looked like a trapped nerve in his neck.
When they returned to the court, the Russians reeled off three straight points to take the initiative.
Germany were soon back on level terms, but errors from Thole and Wickler at the net saw Russia go into a commanding 12-8 lead.
There was only one winner from there with 28-year-old Krasilnikov, who was fourth at Rio 2016 with Konstantin Semenov, booking a return to the Olympic Games in his first season with his new young partner.
Canadians defeat neighbours to make history
On Saturday, Sarah Pavan and Melissa Humana-Paredes secured their spot in Tokyo as they claimed Canada's first beach volleyball world title.
As the score suggests, there was little to choose between the two sides.
But it was the Canadian duo, who were fourth in 2017 having joined forces after Rio 2016, who scored the points at the crucial times.
Humana-Paredes told FIVB, "The last two weeks have been incredible. It wasn’t pretty at times; it wasn’t the best we’ve ever played but we managed to stay together and fight.
"It was all heart, we wanted this so bad and now we have it, and it’s the best feeling ever." - Melissa Humana-Paredes after winning the world title with Sarah Pavan
For Ross, who won the world title in 2009 with her current coach Jen Kessy, it was a big disappointment although there was plenty to take from the event.
The 37-year-old said, "This is the best I’ve ever done at a World Championships in an Olympic qualifying year by far, and it goes a long way toward Tokyo so we’re proud about that.
"But it stings to not have a gold at World Championships. For me even more it doesn’t matter what match it was, it was how I played, how we played as a team and to not pull that out, it hurts a lot."
Competition for the two American spots in Tokyo is fierce, but this showing has put Ross and Klineman in good shape to secure a place in Tokyo.
What next for Olympic qualification?
There are 24 teams in each competition at Tokyo 2020 with a maximum of two pairs per country per gender.
One place has already been allocated to hosts Japan with the world champions in Hamburg taking the next spot.
Two places are up for grabs in September's Olympic Qualifying Tournament in Haiyang, China with countries sending just one team per gender.
Then on 15th June next year, the top 15 in the Olympic rankings - not including those who have already qualified - will go to Japan.
The last five places will go to the winners of each of the five Continental Cup events taking place in late June.
The system means there is an intense battle between the top teams from countries like the United States and Brazil to qualify.
Ross and Klineman will hope to go to Haiyang in September and clinch one of the two available American women's berths.
Their main rivals are Summer Ross and Sara Hughes who were knocked out in the quarter-finals by April Ross and Klineman.