To reduce cost in a hydraulic motor with a lock mechanism.
This hydraulic motor includes a cylinder chamber 5 formed in a cylinder block 3, a piston 7 fitted in the cylinder chamber 5, a pair of suction-discharge passages 13 and 14 for sucking-discharging pressure oil to the cylinder chamber 5, a recessed part 20 embedded in the cylinder block 3 and the lock mechanism 21 opposed to the recessed part 20, wherein the lock mechanism 21 has a locking piston 22 fitted to the recessed part 20, a cylinder chamber 24 for storing the locking piston 22 and a spring 25 for energizing the locking piston 22 to the recessed part 20 side. A shuttle valve 40 is connected to the pair of suction-discharge passages 13 and 14, and a first inlet port 41 is connected to one suction-discharge passage 13, and a second inlet port 42 is connected to the other suction-discharge passage 14, and an outlet port 43 is connected to a control port 26 of the cylinder chamber 24.