We show how magnetic observations of the Sun can be used in conjunction with an axisymmetric flux-transport solar dynamo model in order to estimate the large-scale meridional circulation throughout the convection zone. Our innovative approach rests on variational data assimilation, whereby the distance between predictions and observations (measured by an objective function) is iteratively minimized by means of an optimization algorithm seeking the meridional flow that best accounts for the data. The minimization is performed using a quasi-Newton technique, which requires knowledge of the sensitivity of the objective function to the meridional flow. That sensitivity is efficiently computed via the integration of the adjoint flux-transport dynamo model. Closed-loop (also known as twin) experiments using synthetic data demonstrate the validity and accuracy of this technique for a variety of meridional flow configurations, ranging from unicellular and equatorially symmetric to multicellular and equatorially asymmetric. In this well-controlled synthetic context, we perform a systematic study of the behavior of our variational approach under different observational configurations by varying their spatial density, temporal density, and noise level, as well as the width of the assimilation window. We find that the method is remarkably robust, leading in most cases to a recovery of the true meridional flow to within better than 1%. These encouraging results are a first step toward using this technique to (i) better constrain the physical processes occurring inside the Sun and (ii) better predict solar activity on decadal timescales. This work is supported by Idex Sorbonne Paris Cite via the DAMSE project.