Recently, microorganism and exogenous melatonin application has been recognized as an efficient biological tool for enhancing salt tolerance and heavy metal detoxification in agriculture crops. Thus, the goal of this study was to isolate and evaluate a novel melatonin‐producing plant growth promoting bacterium. With high‐throughput whole genome sequencing, phytohormone measurements, expression profiling, and biochemical analysis, we can identify a novel PGPB that produces melatonin and unravel how it promotes soybean growth and development and protects against salt and Cd stress. We identify the melatonin synthesis pathway (tryptophan→tryptamine→serotonin melatonin) of the halotolerant (NaCl > 800 mM) and heavy metal‐resistant (Cd >3 mM) rhizobacterium Bacillus safensis EH143 and use it to treat soybean plants subjected to Cd and NaCl stresses. Results show that EH143 will highly bioaccumulate heavy metals and significantly improve P and Ca2+ uptake and the K+/Na+ (93%↑under salt stress) ratio while reducing Cd uptake (49% under Cd stress) in shoots. This activity was supported by the expression of the ion regulator HKT1, MYPB67, and the calcium sensors CDPK5 and CaMK1 which ultimately led to increased plant growth. EH143 significantly decreased ABA content in shoots by 13%, 20%, and 34% and increased SA biosynthesis in shoots by 14.8%, 31%, and 48.2% in control, salt, and Cd‐treated plants, upregulating CYP707A1 and CYP707A2 and PAL1 and ICS, respectively. The melatonin content significantly decreased along with a reduced expression of ASMT3 following treatment with EH143; moreover, reduced expression of peroxidase (POD) and superoxide dismutase (SOD) by 134.5% and 39% under salt+Cd stress, respectively and increased level of total amino acids were observed. Whole‐genome sequencing and annotation of EH143 revealed the presence of the melatonin precursor tryptophan synthase (trpA, trpB, trpS), metal and other ion regulators (Cd: cadA, potassium: KtrA and KtrB, phosphate: glpT, calcium: yloB, the sodium/glucose cotransporter: sgIT, and the magnesium transporter: mgtE), and enzyme activators (including the siderophore transport proteins yfiZ and yfhA, the SOD sodA, the catalase katA1, and the glutathione regulator KefG) that may be involved in programming the plant metabolic system. As a consequence, EH143 treatment significantly reduced the contents of lipid peroxidation (O2‐, MDA, and H2O2) up to 69%, 46%, and 29% in plants under salt+Cd stress, respectively. These findings suggest that EH143 could be a potent biofertilizer to alleviate NaCl and Cd toxicity in crops and serve as an alternative substitute for exogenous melatonin application.