There is no longitudinal evidence on risk factors for gang membership in low- and middle-income countries, despite organized crime groups posing major challenges, including high homicide rates in Latin America. Furthermore, adverse childhood experiences (ACEs) have been largely overlooked in gang-related research worldwide. To examine the associations of ACEs up to 15 years of age with past-year gang membership at 18 years of age and to compare crime and criminal justice involvement between gang members and non-gang members. This cohort study assessed children from the 1993 Pelotas (Brazil) Birth Cohort-an ongoing population-based, prospective study. Assessments were undertaken perinatally (1993) and when the children were ages 11 (2004), 15 (2008), 18 (2011), and 22 (2015) years. All children born in 1993 were eligible (N = 5265), and 5249 (99.7%) were enrolled at birth. The study sample (N = 3794 [72.1%]) included those with complete data on ACEs. Data analyses were conducted from February to August 2024. Twelve ACEs were assessed up to 15 years of age via child self-report and/or maternal report, including physical neglect, physical abuse, emotional abuse, sexual abuse, domestic violence, maternal mental illness, parental divorce, ever being separated from parents, parental death, poverty, discrimination, and neighborhood fear. These experiences were examined using a single adversity approach, cumulative risk, and latent classes. The main outcome was past-year gang membership at 18 years of age, assessed via self-report and analyzed using multivariate imputation. Of 3794 participants, 1964 (51.8%) were female and 1830 (48.2%) were male, and 703 (18.5%) were Black, 2922 (77.0%) were White, and 169 (4.5%) were coded as "other" race or ethnicity (no additional details are available to further disaggregate the other category). On the basis of the imputed data, 1.6% (SE, 0.2 percentage points) of participants reported gang membership at 18 years of age. Physical abuse (odds ratio [OR], 2.76; 95% CI, 1.27-5.98), emotional abuse (OR, 2.76; 95% CI, 1.51-5.02), domestic violence (OR, 3.39; 95% CI, 1.77-6.48), parental divorce (OR, 2.04; 95% CI, 1.17-3.54), and separation from parents (OR, 3.13; 95% CI, 1.54-6.37) were associated with an increased risk of gang membership. A dose-response association was observed, with 4 or more ACEs increasing the risk (OR, 8.86; 95% CI, 2.24-35.08). In latent class analysis, the class with child maltreatment and household challenges was associated with a higher risk of gang membership than the low-adversities class (OR, 7.10; 95% CI, 2.37-21.28). There was no robust evidence that children exposed to household challenges and social risks were at increased risk of gang membership (OR, 2.28; 95% CI, 0.46-11.25). In this prospective cohort study, ACEs, particularly child maltreatment and family conflict, were associated with gang involvement when examined individually, cumulatively, and as clusters in a high-crime environment in Brazil. These findings underscore the value of integrating the ACE framework into gang-related research and the potential to reduce gang-related crime by reducing ACEs.