Cephalosporins are licensed for treatment of severe bacterial infections in different species. However, the effect of these antimicrobials on the fecal microbiome and potential spread of resistance-associated genes causes great concern. This highlights the need to understand the impact of cephalosporins on the porcine fecal microbiome and resistome. A combination of long-read 16S rRNA gene and shotgun metagenomic sequencing was applied to investigate the effect of conventional treatment with either ceftiofur (3 mg.kg−1intramuscular, 3 consecutive days) or cefquinome (2 mg.kg−1intramuscular, 5 consecutive days) on the porcine microbiome and resistome. Fecal samples were collected from 17 pigs (6 ceftiofur treated, 6 cefquinome treated, 5 control pigs) at four different timepoints. Treatment with ceftiofur resulted in an increase in Proteobacteria members on microbiome level, while on resistome level selection inTetQcontainingBacteroides,CfxA6containingPrevotellaandblaTEM-1containingEscherichia coliwas observed. Cefquinome treatment resulted in a decline in overall species richness (α-diversity) and increase in Proteobacteria members. On genus level, administration of cefquinome significantly affected more genera than ceftiofur (18 vs 8). On resistome level, cefquinome resulted in a significant increase of six antimicrobial resistance genes, with no clear correlation with certain genera. For both antimicrobials, the resistome levels returned back to the control levels 21 days post-treatment. Overall, our study provides novel insights on the effect of specific cephalosporins on the porcine gut microbiome and resistome after conventional intramuscular treatment. These results might contribute to better tailoring of the most ideal treatment strategy for some bacterial infections.Supplementary InformationThe online version contains supplementary material available at 10.1186/s13567-023-01176-8.