A novel method for three-dimensional variational assimilation of Lagrangian data with a primitive-equation ocean model is proposed. The assimilation scheme was implemented in the Mediterranean ocean Forecasting System and evaluated for a 4-month period. Four experiments were designed to assess the impact of trajectory assimilation on the model output, i.e. the sea-surface height, velocity, temperature and salinity fields. It was found from the drifter and Argo trajectory assimilation experiment that the forecast skill of surface-drifter trajectories improved by 15 %, that of intermediate-depth float trajectories by 20 %, and moreover, that the forecasted sea-surface height fields improved locally by 5 % compared to satellite data, while the quality of the temperature and salinity fields remained at previous levels. In conclusion, the addition of Lagrangian trajectory assimilation proved to reduce the uncertainties in the model fields, thus yielding a higher accuracy of the ocean forecasts.