In epidemics such as COVID‐19, major changes need to be made to the population's behavior to prevent infection and stop disease transmission. The three most recommended preventive measures are wearing a mask, washing hands with soap or hydroalcoholic gel, and watching an interpersonal distance of at least two meters (3W) from other people. This study aimed to assess adherence to these COVID‐19‐related three preventive measures and its association with knowledge, attitudes, risk perception, and practices in Spain. The COSMO‐Spain survey, based on the WHO Behavioral Insights questionnaire on COVID‐19, was conducted in the general Spanish population using an online questionnaire (n = 1,033). Sociodemographic, knowledge, attitudes, practices, and risk perception variables were included. A multivariable logistic regression model was carried out to evaluate the factors associated with compliance with the three preventive measures. Half of the respondents (49.8%) were women with a median age of 45 (Inter‐quartile Range, IR = 21) years. In the logistic regression, the factors associated with 3W compliance were being over 45 years; knowing about how COVID‐19 spreads and wearing masks properly; appropriate attitudes towards COVID‐19 (greater agreement with mandatory mask use); high risk perception (feeling that the coronavirus is spreading rapidly, being concerned about non‐mask wearers), and adherence to other preventive measures against COVID‐19, such as staying at home. Adequate knowledge, attitudes and risk perception are determinants of 3W compliance. Developing effective health education programs and frequent communication strategies are necessary, particularly for those who adhere less to preventive measures.