Intracellular membrane trafficking, which is involved in diverse cellular processes, is dynamic and difficult to study in a spatiotemporal manner. Here we report an optogenetic strategy, termed light-activated reversible inhibition by assembled trap of intracellular membranes (IM-LARIAT), that uses various Rab GTPases combined with blue-light-induced hetero-interaction between cryptochrome 2 and CIB1. In this system, illumination induces a rapid and reversible intracellular membrane aggregation that disrupts the dynamics and functions of the targeted membrane. We applied IM-LARIAT to specifically perturb several Rab-mediated trafficking processes, including receptor transport, protein sorting and secretion, and signaling initiated from endosomes. We finally used this tool to reveal different functions of local Rab5-mediated and Rab11-mediated membrane trafficking in growth cones and soma of young hippocampal neurons. Our results show that IM-LARIAT is a versatile tool that can be used to dissect spatiotemporal functions of intracellular membranes in diverse systems.