Hagi was less than two years old the last time Romania reached the knockout stages of a European Championship, in the summer of 2000.
His clever skill inside the box helped earn him a penalty against Slovakia, and he was lively throughout his 67 minutes on the pitch, firing the rebound over from Andrei Ratiu’s curled effort.
Marin’s 30-yard free-kick arrowed narrowly wide while Denis Dragus dragged an effort past the post as Romania pushed for a second goal.
Slovakia also pushed for victory with David Strelec’s shot from inside the box well saved by the feet of Florin Nita and Lukas Haraslin’s low-struck effort curling narrowly wide of the post.
Duda’s goal meant he became the first player to score for Slovakia at two major international tournaments, also netting against Wales in Euro 2016.
There was a party atmosphere at full-time for both sets of fans and players as their Euro journeys continued.
Romania boss Edward Iordanescu was pleased that his side made it out of their group in front of plenty of joyful fans.
“I believed in the players from the very beginning. We have potential and personality. We have found the spirit that we must never lose,” he said.
“We were losing again but we came back with intelligence, heart and balance. We have written history. This is the generation of soul. It is a fantastic generation.
“Virtually the whole stadium was yellow. Thank you to everyone here and everyone at home in Romania. I’m sure they are all celebrating and will be proud.“
Sophie Anderson, a UK-based writer, is your guide to the latest trends, viral sensations, and internet phenomena. With a finger on the pulse of digital culture, she explores what’s trending across social media and pop culture, keeping readers in the know about the latest online sensations.