A hydraulic cylinder (5A-5G) comprising a cylinder main body in which a cylinder bore is formed, a piston member including a piston portion that is installed in the cylinder bore so as to be movable therein in its axial direction and an output rod, and at least a single hydraulic pressure operation chamber that is defined within the cylinder bore between the piston portion and a head side end wall of the cylinder main body, characterized by comprising: a rod insertion hole formed in said piston portion and said output rod so as to communicate with said hydraulic pressure operation chamber; an auxiliary rod that is provided to said head side end wall so as to project into the cylinder bore, and that can be inserted into said rod insertion hole; a rod fitting hole that is formed so as to penetrate through said head side end wall and said auxiliary rod in an axial direction; a movable rod that is fitted in said rod fitting hole, and of which an end portion toward said head side end wall projects to an exterior from said rod fitting hole; a movement restriction mechanism comprising a plurality of balls fitted on said auxiliary rod so as to be individually movable in radial directions and an annular concave portion formed on said movable rod so as to be capable of engaging with said plurality of balls; said movement restriction mechanism being constituted so as to prohibit shifting of said movable rod in said axial direction in a state in which a lower end of said piston portion is positioned in a first region within the cylinder bore through engaging of said plurality of balls with said annular concave portion, and to permit shifting of said movable rod in said axial direction in a state in which the lower end of said piston portion is positioned in a second region different from said first region within the cylinder bore through disengaging of said plurality of balls from said annular concave portion to shift said movable rod by a predetermined distance due to hydraulic pressure in said rod insertion hole in the direction in which an amount of projection to the exterior from said rod fitting hole increases; and a detection switch that detects whether said movable rod has shifted or not, and that outputs a detection signal. a rod insertion hole formed in said piston portion and said output rod so as to communicate with said hydraulic pressure operation chamber; an auxiliary rod that is provided to said head side end wall so as to project into the cylinder bore, and that can be inserted into said rod insertion hole; a rod fitting hole that is formed so as to penetrate through said head side end wall and said auxiliary rod in an axial direction; a movable rod that is fitted in said rod fitting hole, and of which an end portion toward said head side end wall projects to an exterior from said rod fitting hole; a movement restriction mechanism comprising a plurality of balls fitted on said auxiliary rod so as to be individually movable in radial directions and an annular concave portion formed on said movable rod so as to be capable of engaging with said plurality of balls; said movement restriction mechanism being constituted so as to prohibit shifting of said movable rod in said axial direction in a state in which a lower end of said piston portion is positioned in a first region within the cylinder bore through engaging of said plurality of balls with said annular concave portion, and to permit shifting of said movable rod in said axial direction in a state in which the lower end of said piston portion is positioned in a second region different from said first region within the cylinder bore through disengaging of said plurality of balls from said annular concave portion to shift said movable rod by a predetermined distance due to hydraulic pressure in said rod insertion hole in the direction in which an amount of projection to the exterior from said rod fitting hole increases; and a detection switch that detects whether said movable rod has shifted or not, and that outputs a detection signal.