The stomatal opening and closing depends on the generation of potassium ion (K+) gradient. During day time, the chloroplast in the guard cells phtosynthesise which leads to the production of ATP. This ATP is used to actively pump the potassium ions of the adjacent cells into the guard cells. Increased K+ concentration in the guard cells makes them hypertonic, so, more water from the adjacent cells is drawn in and the cells become more turgid and they move outwards opening the stomatal pore. The reverse happens at night. The K+ ions leak out thus reducing the turgor of guard cells and the stomatal pore closes.