In recent years, social media has increasingly become an important platform for political campaigns, especially elections. It remains elusive how exactly public discourse is driven by the intricate interplay between individual socio-cognitive biases, dueling campaign efforts, and social media platforms. We examine this complex socio-political process by integrating observed retweet networks from the 2016 political networks with an agent-based model of political opinion formation and network structure. Here we show that the range of political viewpoints individuals are willing to consider is a key determinant in the formation of polarized networks and the emergence of echo chambers. We also find that winning majority support in public discourse is determined by both the effort exerted by campaigns and the relative ideological positioning of opposing campaigns. Our results demonstrate how public discourse and political polarization can be modeled as an interactive process of shifting individual opinions, evolving social networks, and political campaigns.