This study analyzes the polarization of narratives on social media during the protests that occurred in Puno, Peru, in 2023, using advanced natural language processing (NLP) and machine learning techniques. 1,378 comments from Facebook and 1,400 from YouTube were collected and preprocessed, applying cleaning, normalization, and stop word removal procedures in Spanish. For sentiment analysis, the VADER model was used, classifying opinions into positive and negative, with an overwhelming predominance of negative comments (96.2%). Additionally, the Latent Dirichlet Allocation (LDA) algorithm was implemented to identify five key narratives: popular power, support for Pedro Castillo, the demand for Dina Baluarte’s resignation, references to symbolic figures, and demands for justice for deaths during the protests. These results show significant sociopolitical polarization on digital platforms, reflecting latent tensions in the population. This analysis demonstrates the potential of NLP and topic modeling tools to monitor and detect polarizing discursive trends in real time, allowing for an early assessment of emerging narratives in crisis contexts. The methodological and predictive implications of the present approach suggest its applicability in future studies on sociopolitical conflicts and digital polarization dynamics.