General practitioners are crucial in the primary healthcare system as well as for epidemic prevention and control. However, few researchers have examined their professional identity. This study investigated the current status of the professional identity of general practitioners in Chongqing, China and explored the effects of psychological capital and patient’s contempt on their professional identity. From December 2021 to January 2022, randomized cluster sampling was used to conduct a cross-sectional online self-assessment questionnaire survey among general practitioners in Chongqing. In total, 2,180 general practitioners working for more than one year were selected. General practitioners’ sense of professional identity, mental health, and sense of patients’ disrespect were measured using the Professional Identity Scale, Psychological Capital Questionnaire, and Patient’s Contempt Questionnaire. Sociodemographic characteristics were also collected. A multiple linear regression model was used to analyze the association between professional identity, psychological capital, and patient’s contempt. The average score for professional identity among general practitioners was 53.59 (SD = 6.42). The scores for self-efficacy, hope, resilience, and optimism (subscales of psychological capital) were 26.87 (SD = 5.70), 26.47 (SD = 5.74), 26.97 (SD = 5.55), and 26.86 (SD = 5.59), respectively. The score for perceived contempt was 34.19 (SD = 7.59). An average monthly income greater than CNY 8,000 (β = 1.018, p < 0.001), work tenure of more than 15 years (β = 0.440, p = 0.001), hope (β = 0.249, p < 0.001) and a higher optimism score (β = 0.333, p < 0.001) were positively correlated with professional identity. Having a bachelor’s degree and above (β = -0.720, p = 0.014), an administrative role (β = -1.456, p < 0.001), self-efficacy (β = -0.122, p < 0.001), and higher patient’s contempt (β = -0.103, p < 0.001) were negatively associated with professional identity. General practitioners in Chongqing demonstrated high professional identity and a strong psychological status during the COVID-19 pandemic. Psychological capital and patient’s contempt were associated with professional identity. To improve general practitioners’ professional identity, stakeholders should promote practitioners’ mental health and physician–patient relationships in China.