Mediator variable M: indirect effect X --> M --> Y
Moderator variable Z: interaction; the effect of X on Y is different for different levels (values) of Z.
See:
Baron, R. M., & Kenny, D. A. (1986). The moderator–mediator variable distinction in social psychological research: Conceptual, strategic, and statistical considerations. Journal of Personality and Social Psychology, 51(6), 1173-1182.
Mediator variable normally explains the relationship between an independent variable and a dependent variable, operating on the causal pathway between them. While, a moderator variable is a variable that influences the strength or direction of the relationship between an independent variable and a dependent variable. Unlike a mediator variable, a moderator variable does not explain the relationship between the independent and dependent variables but affects the nature or conditions under which the relationship occurs.
actually I regard the old Baron/Kenny paper (and their famous statistical approach) as a rather "suboptimal" source because of the constant mixing of causal/theoretical and empirical/statistical issues. For instance, they define a mediator as a variable that "accounts for the relation between the predictor and the criterion". Besides the unfortunate use of merely predictive concepts ("predictor" and "criterion" instead of cause / effect), this definition would also hold true for confounders that create a (spurious) "relation" and hence "account" for this relation. Then they use examples which are clearly causal. Their approach of testing mediation is completly bogus and is a direct consequence of this non-causal conceptualization (together with the irrelevant pre-assumption that X and Y must be strongly related which is not relevant when having an "inconsistent mediation" (and that although Dave Kenny discusses inconsistent mediation on his website....).
To summary all of that: A mediator is a causal concept and means that X causes M (the mediator) which then causes Y. This definition changes nothing in the empirical difficulties to support the proposed mediation--especially in non-experimental situation. Applying the ususal regression approach a la Baron/Kenny (which is still used in 90% of the cases) is unfortunately not a great support, as the majority of situations imply partial mediation in which a simple regression appraoch is not able to differentiate the supposed model from appr. 40 alternative (!) model structures.
Thoemmes, F. (2015). Reversing arrows in mediation models does not distinguish plausible models. Basic and Applied Social Psychology, 37(4), 226-234. https://doi.org/10.1080/01973533.2015.1049351
Kline, R. B. (2015). The mediation myth. Basic and Applied Social Psychology, 37(4), 202-213. https://doi.org/10.1080/01973533.2015.1049349