Abstract Background Transactional sex, which includes exchanging sex for material goods, services, or money, is a key HIV risk factor. Risk patterns associated with transactional sex among men who have sex with men (MSM) in Sweden, where buying sexual services is illegal, have not been examined earlier. This study aims to assess whether transactional sex (both buying and selling), country of birth, and migration-related factors (described by country of origin) are associated with self-reported HIV status among MSM in Sweden. Methods We analyzed secondary data from the 2017 European MSM Internet Survey (EMIS-2017), including participants reporting to live in Sweden (n = 4443). Using multivariate logistic regression analysis, we aimed to understand factors related to involvement in transactional sex and risk of HIV acquisition. Results Among the respondents, 5.4% reported living with HIV, with 8.8% of foreign-born MSM and 4.8% of Swedish-born MSM. The multivariable analysis showed that both selling and buying sex in the past five years increased the odds of reporting a positive HIV serostatus among all participants. Stratifying by transactional sex exposure and country of birth showed an HIV prevalence increase for all groups. Foreign-born selling or buying sex ever in the last five years had the highest prevalence of all groups (ranging from 17.8 to 19.1%). Other factors associated with a positive HIV status were age, outness, sex with a woman in the past twelve months, and condom use. Conclusions The relatively high reported HIV prevalence supports the need for HIV prevention, including the scale-up of access to pre-exposure prophylaxis to foreign-born MSM. A transparent discussion about risk factors and socioeconomic structures contributing to risk behaviors, including transactional sex, is needed. Key messages • Engaging in transactional sex increases the HIV risk among MSM in Sweden, particularly among foreign-born MSM. • HIV prevention needs to address the socioeconomic factors contributing to risky behaviors, such as transactional sex.