BackgroundClinical evidence demonstrating a longitudinal association between prescribed medications and sarcopenia onset is lacking. We investigated the association of polypharmacy (the use of five or more medications) and potentially inappropriate medications (PIMs) with sarcopenia risk in community-dwelling older adults.MethodsIn this longitudinal population-based cohort study, 2,044 older residents with no long-term care needs were randomly selected from a community in Kashiwa, Japan. Baseline data collection was conducted in 2012, with follow-ups in 2013, 2014, 2016, 2018, and 2021. Prescribed medications and PIMs (drugs listed in the Screening Tool for Older Person’s Appropriate Prescriptions for the Japanese or potentially muscle-wasting drugs) were identified through interviews. New-onset sarcopenia was identified according to the 2019 criteria of the Asian Working Group for Sarcopenia over a 9-year period and analyzed. We used Cox proportional hazards models to test the longitudinal association of prescribed medications with sarcopenia onset.ResultsOf the 1,549 participants without sarcopenia at baseline (mean age, 72.5 ± 5.5 years; 49.1% women; median and interquartile range, 6.0 [4.0–9.0] years), 230 experienced new-onset sarcopenia during the follow-up. After adjusting for confounders, polypharmacy combined with PIM use was strongly associated with new-onset sarcopenia (adjusted hazard ratio, 2.35; 95% confidence interval, 1.58–3.51;P <0.001). No significant associations were observed for either PIM use or polypharmacy alone.ConclusionsPolypharmacy combined with PIM use, but not polypharmacy alone, was associated with an increased risk of new-onset sarcopenia over the 9-year follow-up period among community-dwelling older adults. Limiting polypharmacy and imposing the prescription of appropriate medications may facilitate sarcopenia prevention.Supplementary InformationThe online version contains supplementary material available at 10.1186/s12877-023-04012-y.