Water hammer is a shock wave transmitted through fluid contained in a piping system. The most basic explanation is that water hammer occurs when a fluid in motion is suddenly forced to stop moving. The momentum of the fluid abruptly stopping creates a pressure wave that travels through the media within the pipe system, subjecting everything in that closed system to significant forces.
Velocity of the flowing water and a sudden disturbance to this flowing water's velocity are the two major factors that create water hammer in a piping system. When the flowing water is stopped abruptly in a piping system, the kinetic energy present in this flowing water rapidly transforms into a pressure rise within the pipe.