Ovechkin tied the game at 2-2 in the second period with a backhand and Malkin wristed a shot high into the roof of the net on a power play for the go-ahead goal.
Danis Zaripov also scored a goal and added two assists.
Viktor Tikhonov and Sergei Shirokov scored a goal each.
Putin watched the game sitting next to Belarus President Alexander Lukashenko in the stands, as the Russian team gained a measure of redemption after a painful loss to Finland in the quarterfinals of the Sochi Olympics just three months ago. It was Russia's fifth gold since the 1991 breakup of the Soviet Union.
The worlds was the first major competition for new Russia coach Oleg Znarok, who has been tasked with reviving the team after the Sochi letdown. Znarok was suspended for the final, however, after making a cut-throat gesture toward a Swedish assistant coach in the semifinals.
His team cruised through this tournament from the start, winning all its 10 games. The Russians scored the most goals of any team (42) and yielded the least (10).
Russia took the lead through Shirokov midway through the first period on a power play, but Iiro Pekarinen tied it up three seconds before the interval.
In the second, Olli Palola scored a power-play goal on a rebound to put the Finns ahead, before Ovechkin and Malkin lived up to their billing as the star attractions of the tournament.
Zaripov added the fourth with a slap shot past Finland goaltender Pekka Rinne on a power play in the third before Tikhonov completed the victory on another power play.
Tikhonov finished as the tournament's top scorer with eight goals.
Znarok joined his celebrating players on the ice after the game.