As we know, there are air spaces in the mesophyll layer which allows carbon dioxide to diffuse in and oxygen to diffuse out, but cell membranes are partially permeable and allow water to diffuse to regions with lower concentration. Yet these air spaces still manage to not get flooded by liquid water. How does this happen?
There has not been not much research on this topic, which has caused lack of definite answer. Sibbernsen et al, 2017 performed a study on response of stomatal opening on filling these air spaces with water. They suggest the existence of a vapor-phase signal (from water) that originates in the mesophyll and causes stomata to open in the light. In another research, Wiebe et al, 1976 were able to remove the air spaces with the use of paraffin oil which infiltrated the spaces. They show that leaf air spaces contain invaginations which are extensions of air space system and increase conductivity of CO2 to the chloroplasts which line these invaginations.
Stomatal transpiration gives a clue to this. When the stomata open, they expose the internal environment to the atmosphere. Due to this, the air spaces get filled with water vapors which, due to concentration gradient, flow outwards from the leaf. To maintain the inner water vapors, more water is evaporated from the nearby cells, which leads to more transpiration. This hints that some water is present all the time in these air spaces in the form of water vapors. However, when the concentration of vapors becomes high, the nearby cells might take in some water or the stomata might open to maintain the concentration. See this article for some details on this.
At last, there is Woolley et al, 1983 which concludes that the mechanism behind the maintenance of these air spaces is still largely unknown.