A simulated annealing optimization algorithm is formulated to optimize parameters of ecosystem models. The optimization is used to directly determine the model parameters required to reproduce the observed data. The optimization routine is formulated in a general manner and is easily modified to include additional information on both the desired model output and the model parameters. From the optimization routine, error analysis of the optimal parameters is provided by the error-covariance matrix which gives both the sensitivity of the model to each model parameter and the correlation coefficients between all pairs of model parameters. In addition, the optimization analysis provides a means of assessing the necessary model complexity required to model the available data. To demonstrate the technique, optimal parameters of three different ecosystem model configurations are determined from nitrate, phytoplankton, mesozooplankton and net phytoplankton productivity measurements at Station P. At Station P, error analysis of the optimal parameters indicates that the data are able to resolve up to 10 independent model parameters. This is always less than the number of unknown model parameters indicating that the optimal solutions are not unique. A simple nitrate-phosphate-zooplankton ecosystem is successful at reproducing the observations. To justify the use of a more complicated model at Station P requires additional data to constrain the optimization routine. Although there is evidence supporting the importance of the microbial loop at Station P, without additional ammonium and bacteria measurements one cannot validate a more complicated model that includes these processes.