A gel system has been widely used in many mature oilfields for water shut-off treatment. In the present study, the hydrophobically associating polymer (HAP) was cross-linked with the polyethylenimine (PEI) to form a HAP/PEI gel system which contains 0.35 wt % HAP and 0.60 wt % PEI. Gelation behaviors of the HAP/PEI gel formed in bottle and in core were studied, respectively. Results show that the gelation behaviors of the gel system were greatly affected by the concentration of HAP and that of PEI. The addition of the sodium chloride or calcium chloride generally resulted in a decrease of the apparent viscosity and an extension of the gelation time. However, a low concentration of sodium chloride led to a slight increase of the gel viscosity in bottle due to the intensification of the hydrophobic association. The rock skeleton of the core had a great effect on the gelation behavior. Compared with the results obtained in bottle, the apparent viscosity of the HAP/PEI gel system in core was obviously reduced, and the gelation time in core was extended two times or even longer. Both the gelation times achieved in bottle and in core decreased with the increase of temperature following the relationship of Arrhenius-type. The activation energy of the HAP/PEI gel system was 41.57 kJ/mol in bottle but increased to 60.95 kJ/mol in core. Data collected from the core flowing tests present a favorable shut-off performance and a strong wash-out resistance of the HAP/PEI gel system. In addition, the in-depth flow diversion and water permeability reduction were two main mechanisms of this gel system for water shut-off treatment.