I was asking the same question to myself the other day and today i finally figured it out.Actually it's not due to vacuum , it is due to the fact that the mug has tiny amount of air trapped inside it.
I am using an approximation that the mug is pulled out slowly i.e without accelerating.

Let the :
- Density of water be $\rho_w$
- The external force that you apply be F
- Atmospheric pressure be $p_o$
The Key thing to notice is that air inside the mug is not exerting the same pressure.
Pressure that trapped air is exerting be $p$
Area of cross section of the mug be $A$
Now since the water is at same horizontal level (at my dashed line ) and the water is at rest . Pressure at the horizontal line is $p_o$.
Now : $p_o=p+\rho_w g h' ====> (p<p_o) $
Let's us say difference in pressure is $\Delta p$
Therefore according my free body diagram we get :
$$F +pA = mg + p_oA $$
$$F = mg + \Delta pA $$
$$F>mg$$
After that, the air enters into the mug and the water spills out.