Calcium ($Ca^{2+}$) signals that are precisely modulated in space and time mediate a myriad of cellular processes, including contraction, excitation, growth, differentiation and apoptosis. However, study of $Ca^{2+}$ responses has been hampered by technological limitations of existing $Ca^{2+}$-modulating tools. Here I present OptoSTIM1, an optogenetic tool for manipulating intracellular $Ca^{2+}$ levels through activation of $Ca^{2+}$-selective endogenous $Ca^{2+}$ release activated $Ca^{2+}$ (CRAC) channels. Using OptoSTIM1, which combines a plant photoreceptor and the CRAC channel regulator STIM1, I quantitatively and qualitatively controlled intracellular $Ca^{2+}$ levels in various biological systems, including zebrafish embryos and human embryonic stem cells. I demonstrate that activating OptoSTIM1 in the CA1 hippocampal region of mice selectively reinforced contextual memory formation. The broad utility of OptoSTIM1 will expand our mechanistic understanding of numerous $Ca^{2+}$-associated processes and facilitate screening for drug candidates that antagonize $Ca^{2+}$ signals.