Background: Cultivating medical talents with professional identity is the ultimate goal of medical education. Nonetheless, the pre-service stage does not create sufficient opportunities to develop their professional identities. Also, there is a lack of long-term empirical data for this process. This longitudinal narrative study involved a dynamic online knowledge community in which students shared confusion, anxiety, and transformation about professional identity. Through capturing their reflections and interactions, the study explored how their professional identities developed over time through the online community in medical school and how this community best supported professional identity development. Method: We collected data from chat records and telephone interviews, using the narrative inquiry method and its interpretative tools to analyze professional identity development. Quantitative analysis was carried out to reveal some influencing factors. Results: Fine-grained analysis showed that medical students experienced a contextual change from individual identity to physician community and a collaborative process to create a supportive environment to develop a professional identity through multi-layered interactions. The analysis also identified that in a virtual community that formed group resonance, medical students balanced their self-identities and professional identity through changed perspectives to engage in selfreflection, with mentor coordination, blended interaction, and facilitating strategies as influencing factors. Our study uniquely presents online learning patterns and identity development trajectories. Conclusions: The study complements the literature about online communities and the professional identity of medical students and has important implications for online informal learning