Multiple countries have recently experienced extreme political polarization, which, in some cases, led to escalation of hate crime, violence and political instability. Besides the much discussed presidential elections in the USA and France, Britain's Brexit vote and Turkish constitutional referendum showed signs of extreme polarization. Among the countries affected, Ukraine faced some of the gravest consequences. In an attempt to understand the mechanisms of these phenomena, we here combine social media analysis with agent-based modelling of opinion dynamics, targeting Ukraine's crisis of 2014. We use Twitter data to quantify changes in the opinion divide and parametrize an extended bounded confidence XY model, which provides a spatio-temporal description of the polarization dynamics. We demonstrate that the level of emotional intensity is a major driving force for polarization that can lead to a spontaneous onset of collective behaviour at a certain degree of homophily and conformity. We find that the critical level of emotional intensity corresponds to a polarization transition, marked by a sudden increase in the degree of involvement and in the opinion bimodality.