Bacillus megaterium is well known as a plant growth-promoting rhizobacterium, but the relevant molecular mechanisms remain unclear. This study aimed to elucidate the effects of B. megaterium HT517 on the growth and development of and the control of disease in greenhouse tomato and its mechanism of action. A pot experiment was conducted to determine the effect of B. megaterium on tomato growth, and this experiment included the HT517 group (
3.2
×
10
8
cfu/pot) and the control group (inoculated with the same amount of sterilized suspension). An antagonistic experiment and a plate confrontation experiment were conducted to study the antagonistic effect of B. megaterium and Fusarium oxysporum f.sp. lycopersici. Liquid chromatography–mass spectrometry was used to determine the metabolite composition and metabolic pathway of HT517. PacBio+Illumina HiSeq sequencing was utilized for map sequencing of the samples. An in-depth analysis of the functional genes related to the secretion of these substances by functional bacteria was conducted. HT517 could secrete organic acids that solubilize phosphorus, promote root growth, secrete auxin, which that promotes early flowering and fruiting, and alkaloids, which control disease, and reduce the incidence of crown rot by 51.0%. The complete genome sequence indicated that the strain comprised one circular chromosome with a length of 5,510,339 bp (including four plasmids in the genome), and the GC content accounted for 37.95%. Seven genes (pyk, aceB, pyc, ackA, gltA, buk, and aroK) related to phosphate solubilization, five genes (trpA, trpB, trpS, TDO2, and idi) related to growth promotion, eight genes (hpaB, pheS, pheT, ileS, pepA, iucD, paaG, and kamA) related to disease control, and one gene cluster of synthetic surfactin were identified in this research. The identification of molecular biological mechanisms for extracellular secretion by the HT517 strain clarified that its organic acids solubilized phosphorus, that auxin promoted growth, and that alkaloids controlled tomato diseases.