The goal of the present chapter is to present in a self-contained manner, elements of differential calculus and stochastic analysis over spaces of probability measures. Such a calculus will play a crucial role in the sequel when we discuss stochastic control of dynamics of the McKean-Vlasov type, and various forms of the master equation for mean field games. After reviewing the standard metric theory of spaces of probability measures, we introduce a notion of differentiability of functions of measures tailor-made to our needs. We provide a thorough analysis of its properties, and relate it to different notions of differentiability which have been used in the existing literature, in particular the geometric notion of Wasserstein gradient. Finally, we derive a first form of chain rule (Itô’s formula) for functions of flows of measures, and we illustrate its versatility on a couple of applications.