Inverse problems use physical measurements along with a computational model to estimate the parameters or state of a system of interest. Errors in measurements and uncertainties in the computational model lead to inaccurate estimates. This work develops a methodology to estimate the impact of different errors on the variational solutions of inverse problems. The focus is on time evolving systems described by ordinary differential equations, and on a particular class of inverse problems, namely, data assimilation. The computational algorithm uses first-order and second-order adjoint models. In a deterministic setting the methodology provides a posteriori error estimates for the inverse solution. In a probabilistic setting it provides an a posteriori quantification of uncertainty in the inverse solution, given the uncertainties in the model and data. Numerical experiments with the shallow water equations in spherical coordinates illustrate the use of the proposed error estimation machinery in both deterministic and probabilistic settings.