Ondrej Duda put Slovakia ahead in the first half but Romania's Razvan Marin equalised with a penalty before the interval. With all four teams in the group earning four points from their three games, Romania finished top having scored more goals than second-placed Belgium.
Slovakia went through in third place thanks to a superior goal difference to fourth-placed Ukraine. It was a memorable moment for Romania, who are into the knockout stages of the Euros for the first time in 24 years.
Romania had only qualified once for the last 16 in their five Euro appearances, but Edward Iordanescu's tenacious side have ended that long drought They responded to Iordanescu's pre-match challenge to make "history" with a combative display fuelled by their army of vociferous fans, who turned the stadium into a sea of yellow.
Slovakia are into the knockout stages of a major tournament for the third time.