HONG KONG—The fight over democracy that erupted into violence in Hong Kong over the weekend exposed a deep generational and economic divide in the city that is poised to shape the city's relationship with mainland China for years to come.

Students have led the push for democracy in Hong Kong all summer, tapping into the frustration felt by their generation, which has struggled with soaring housing costs, an economy dominated by several large conglomerates and competition from mainland Chinese for services such as education...