The production, optimization, and characterization of the bioflocculant QZ-7 synthesized by a novel Bacillus salmalaya strain 139SI isolated from a private farm soil in Selangor, Malaysia, are reported. The flocculating activity of bioflocculant QZ-7 present in the selected strain was found to be 83.3%. The optimal culture for flocculant production was achieved after cultivation at 35.5 °C for 72 h at pH 7 ± 0.2, with an inoculum size of 5% (v/v) and sucrose and yeast extract as carbon and nitrogen sources. The maximum flocculating activity was found to be 92.6%. Chemical analysis revealed that the pure bioflocculant consisted of 79.08% carbohydrates and 15.4% proteins. The average molecular weight of the bioflocculant was calculated to be 5.13 × 105 Da. Infrared spectrometric analysis showed the presence of carboxyl (COO-), hydroxyl (-OH), and amino (-NH2) groups, polysaccharides and proteins. The bioflocculant QZ-7 exhibited a wide pH stability range from 4 to 7, with a flocculation activity of 85% at pH 7 ± 0.2. In addition, QZ-7 was thermally stable and retained more than 80% of its flocculating activity after being heated at 80 °C for 30 min. SEM analysis revealed that QZ-7 exhibited a clear crystalline brick-shaped structure. After treating wastewater, the bioflocculant QZ-7 showed significant flocculation performance with a COD removal efficiency of 93%, whereas a BOD removal efficiency of 92.4% was observed in the B. salmalaya strain 139SI. These values indicate the promising applications of the bioflocculant QZ-7 in wastewater treatment.