That was in violation of the strict neutrality rules the International Olympic Committee (IOC) had set out for the OAR team, which was made up of more than 160 Russian athletes who were able to prove they hadn't been doping after their country was banned from PyeongChang 2018 because of alleged state-sponsored doping before and during the 2014 Sochi Olympics.
"I think from the beginning we had this inkling inside each one of us and then, as we lined up, we said we will sing the anthem and that's it," Bogdan Kiselevich told reporters after the OAR's 4-3 overtime win.
*We're prohibited from having the flag so we had to do something at least. We sang because we're Russian people and when you win, the anthem is played. It was in our souls and heart."
Questioned whether he was afraid the team would be punished for singing the anthem, Kiselevich responded: "It's freedom of speech."
The OAR team's Nikita Gusev had scored in the final minute of regulation to force overtime.
Kirill Kaprizov then scored the gold-medal-clinching goal to hand the team its 17th medal, but only its second gold medal of the Games. The last time Russia won's men's Olympic ice hockey gold was back in 1992 when it competed as the Unified Team following the break up of the Soviet Union.
A few hours before the ice hockey finals, the IOC had decided not to let the OAR athletes march into the Olympic stadium later for Sunday's Closing Ceremony under the Russian flag and in their national colors.
After the OAR team's ice hockey win, US slopestyle skier Gus Kenworthy tweeted: "Russia's biggest win since the 2016 US Presidential election."
Germany silver, Canada bronze
Germany, the 60-1 outsiders, had pulled off one of the biggest upsets in Olympic history when it knocked out nine-time Olympic champions Canada in the semifinals, but there was no fairytale ending.
Despite Sunday's defeat, Germany's 2018 silver medal ended a 42-year medal drought in men's ice hockey. No German team had reached the Olympic podium since West Germany claimed bronze at the Innsbruck Games in 1976.
Canada, which had won three gold medals in the past four Olympics, defeated the Czech Republic on Saturday to take bronze.