Precipitation of struvite can be conceived as one of the main processes for recovering P and N from wastewater. This paper developed a thermodynamic model of struvite precipitation to predict the potential P recovery (PR) from wastewater streams by NaOH or HCl and MgCl 2 .6H 2 O addition using the Gibbs free energy as objective function, by implementation of a hybrid optimization technique based on successive use of pattern search algorithm (PS) and classical sequential quadratic programming (SQP) method. The simulated PR, and equilibrium pH data were validated using synthetic wastewater in batch process; showing good correlations with the experimental data in both cases: R 2 =99.4% and R 2 =99.3% respectively. The validated model was used to evaluate the influence of molar ratios Mg/P (1.0, 1.2, 1.5, 2.0) and N/P (1.0, 2.0) for a orthophosphate phosphorus concentration (P-OP) of 200 ppm. The maximum PR reached for each combination of concentrations tested were evaluated, resulting the molar ratios N/P=2.0 and Mg/P=1.20 (pH=8.94) as a good industrial operation candidate, because achieves high PR (97.6%) at reasonable lower Mg concentration. For this condition, the effect of ionic strength produced by nonreactive ions (I *) was studied, showing that increases in I * reduces the optimum PR achieved.