The main purpose of this study was to develop a novel, in situ gel system for sustained delivery of ranitidine hydrochloride. Ranitidine in situ gels at 0.2%, 0.5%, and 1.0% gellan gum concentration (w/v) were prepared, respectively, and characterized in terms of preparation, viscosity and in vitro release. The viscosity of the gellan gum formulations in solution increased with increasing concentrations of gellan gum. In vitro study showed that the release of ranitidine from these gels was characterized by an initial phase of high release (burst effect) and translated to the second phase of moderate release. Single photon emission computing tomography technique was used to evaluate the stomach residence time of gel containing 99mTc tracer. The animal experiment suggested in situ gel had feasibility of forming gels in stomach and sustained the ranitidine release from the gels over the period of at least 8 h. In conclusion, the in situ gel system is a promising approach for the oral delivery of ranitidine for the therapeutic effects improvement.