The visitors were caught cold after three minutes when Zlatko Junuzovic curled an excellent free-kick beyond the goalkeeper.
Ukraine levelled after 56 minutes, Oleh Gusyev tapping the ball in from close range following a through ball from Andriy Yarmolenko.
Marko Arnautovic restored Austria's lead six minutes later with a powerful effort low into the corner.
Gusyev, though, struck again in the 65th minute with a long-range thunderbolt of a shot into the top corner.
Arnautovic then grabbed the winner with two minutes left to play.
Ukraine, drawn with France, England and Sweden in Group D, take on Turkey in a final warm-up in Ingolstadt on Tuesday.
Their first match in the Euros is against Sweden in Kiev on June 11. Poland are also co-hosts.
Get the best features, fun and footballing frolics straight to your inbox every week.
Thank you for signing up to Four Four Two. You will receive a verification email shortly.
There was a problem. Please refresh the page and try again.