The country scored 534 points with its song 1944, about the deportation of Crimean Tatars under Josef Stalin.
Australia finished second with 511 points, while Russia - which was the favourite going into the competition - was third with 491 points.
Joe and Jake, who represented the UK with their song You're Not Alone, finished in 24th place with 62 points.
Jamala is the first ever Crimean Tatar to perform at the contest and caused controversy ahead of the show over her political song.
The song references the year when Stalin deported almost all of the ethnic group from its native region of Crimea in what was then Soviet Russia (later to become part of Ukraine).
Ukraine confounded the bookmakers and Eurovision commentators who had been convinced that Russia - or possibly Australia - would win.
Russia's CG effects and the brilliance of Australia's singing weren't enough to defeat jazz artist Jamala.
Russia was the bookmakers' favourite for so long, possibly because it was so similar to last year's Swedish winner. Ukraine appears to have slipped past it under the radar.
Simon Bennett, head of the International OGAE Eurovision fan club, told the BBC that former Soviet countries that would "normally vote for Russia" sent it a message by voting for Ukraine instead.