Introduction: Self-medication with antibiotics (SMA) is a widespread problem in developing nations, including Tanzania.Methods: This study compared knowledge, attitudes, practices, and factors influencing antibiotic SMA among medical and non-medical students.Results: The prevalence of SMA among medical students was 49.1% and 59.2% among non-medical students, respectively. The mean knowledge score of medical students (6.4) was significantly higher (p-value <0.001) than that of non-medical students (5.6). The main factors influencing SMA practices were the availability of antibiotics without a prescription, easy access to pharmacies, and a lack of knowledge about the risks of SMA. This experience was pivotal in influencing medical students to take antibiotics, with a substantial proportion of 67.5% as opposed to 59.4% of non-medical students. Medical students were 1.6 times more likely to self-medicate with antibiotics than non-medical students (Adjusted Odds Ratio (AOR): 1.6; 95% Confidence Interval (CI): 1.2–2.3, p-value = 0.004). Age was also associated with self-medication, with an AOR of 1.1 (95% CI: 1.04–1.2, p-value = 0.006) per year increase in age. Additionally, attitude was associated with self-medication, with an AOR of 1.05 (95% CI: 1.04–1.1, p-value = 0.001) per unit increase in attitude score.Discussion: No significant associations were found between sex, marital status, having children, year of study, knowledge score, and self-medication with antibiotics. This study emphasizes the importance of educational interventions and public awareness campaigns to promote antimicrobial stewardship, appropriate antibiotic use, and preventing pharmacies from dispensing antibiotics without a prescription.