Introducing specific plant growth-promoting bacteria (PGPB) into the soil ecological system is vital to improve nutrient utilization efficiency. Suitable combinations of inoculant and fertilisation particularly phosphorus (P) play important roles in enhancing the effects of PGPB. The ecotoxic risks of antibiotics in agro-ecosystems are of great concern. A pot experiment was conducted to explore the effects of P fertilisation, Bacillus amyloliquefaciens inoculation, and oxytetracycline (OTC) on the bacterial community and the genes related to soil nitrogen (N) and phosphorus (P) conversion in the rhizosphere of alfalfa. Soil bacterial biodiversity including the number of species and richness was reduced by P fertilisation and OTC addition, enhanced by the inoculation of B. amyloliquefaciens without OTC addition. OTC increased the correlations among bacterial genera. The abundance of total 16S rRNA genes, N- and P-cycling functional genes was decreased by OTC in most cases, but increased at 0 mg P kg−1 and 160 mg OTC kg−1 (P–OTC+) when the soil was inoculated with B. amyloliquefaciens. The relative abundance of five bacterial genera, including Mesorhizobium and some unitalicise uncultured genera, increased at P–OTC+ when inoculated with B. amyloliquefaciens. These genera might use the necromass of some microbes killed by OTC as a nutrient substrate for enhanced growth, thus enhancing the expression of N- and P-cycling functional genes. Overall, OTC altered the effects of P fertilisation and B. amyloliquefaciens inoculation on the bacterial community, N- and P-cycling functional genes in the rhizosphere of alfalfa.