The gut microbiota in cattle is essential for protein, energy, and vitamin production and hence, microbiota perturbations can affect cattle performance. This study evaluated the effect of intramammary (IMM) ceftiofur treatment and lactation stage on the functional gut microbiome and metabolome. Forty dairy cows were enrolled at dry-off. Half received IMM ceftiofur and a non-antibiotic teat sealant containing bismuth subnitrate (cases), while the other half received the teat sealant (controls). Fecal samples were collected before treatment at dry off, during the dry period (weeks 1 and 5) and the first week after calving (week 9). Shotgun metagenomic sequencing was applied to predict microbial metabolic pathways whereas untargeted metabolomics was used identify polar and nonpolar metabolites. Compared to controls, long-term changes were observed in the cows given ceftiofur, including a lower abundance of microbial pathways linked to energy production, amino acid biosynthesis, and other vital molecules. The metabolome of treated cows had elevated levels of stachyose, phosphatidylethanolamine diacylglycerol (PE-DAG), and inosine a week after the IMM ceftiofur application, indicating alterations in microbial fermentation, lipid metabolism, energy, and cellular signaling. Differences were also observed by sampling, with cows in late lactation having more diverse metabolic pathways and a unique metabolome containing higher levels of histamine and histamine-producing bacteria. These data illustrate how IMM ceftiofur treatment can alter the functionality of the hindgut metabolome and microbiome. Understanding how antibiotics and lactation stages, which are each characterized by unique diets and physiology, impact the function of resident microbes is critical to define normal gut function in dairy cattle.