A gear pump (1; 201) or a gear motor comprising: a casing; a drive gear and a driven gear each configured as a helical gear, the drive gear and the driven gear meshing with each other in the casing and partitioning an inside of the casing so as to include a high-pressure space (18b; 118b; 218b) and a low-pressure space (18a, 18c; 118a, 118c; 218a; 318a); and a drive-side space and an idler-side space each configured to allow pressure therein to become higher than a pressure in the low-pressure space (18a, 18c; 118a, 118c; 218a; 318a), the drive-side space facing an end portion of a drive shaft (4a; 4b) rotatably supporting the drive gear, the idler-side space facing an end portion of an idler shaft (5a; 5b) rotatably supporting the driven gear, wherein the end portion of the drive shaft (4a; 4b) is pushed in a predetermined direction by working fluid supplied to the drive-side space, and the end portion of the idler shaft (5a; 5b) is pushed in the predetermined direction by working fluid supplied to the idler-side space, characterized in further comprising: a drive-side opening closing member configured so that when the pressure in the drive-side space is not higher than a drive-side intermediate pressure, which is lower than a pressure in the high-pressure space (18b; 118b; 218b), fluid communication between the drive-side space and the low-pressure space (18a, 18c; 118a, 118c; 218a; 318a) is not allowed, and when the pressure in the drive-side space exceeds the drive-side intermediate pressure, fluid communication between the drive-side space and the low-pressure space (18a, 18c; 118a, 118c; 218a; 318a) is allowed; and an idler-side opening closing member configured so that when the pressure in the idler-side space is not higher than an idler-side intermediate pressure, which is lower than the pressure in the high-pressure space (18b; 118b; 218b), fluid communication between the idler-side space and the low-pressure space (18a, 18c; 118a, 118c; 218a; 318a) is not allowed, and when the pressure in the idler-side space exceeds the idler-side intermediate pressure, fluid communication between the idler-side space and the low-pressure space (18a, 18c; 118a, 118c; 218a; 318a) is allowed. a casing; a drive gear and a driven gear each configured as a helical gear, the drive gear and the driven gear meshing with each other in the casing and partitioning an inside of the casing so as to include a high-pressure space (18b; 118b; 218b) and a low-pressure space (18a, 18c; 118a, 118c; 218a; 318a); and a drive-side space and an idler-side space each configured to allow pressure therein to become higher than a pressure in the low-pressure space (18a, 18c; 118a, 118c; 218a; 318a), the drive-side space facing an end portion of a drive shaft (4a; 4b) rotatably supporting the drive gear, the idler-side space facing an end portion of an idler shaft (5a; 5b) rotatably supporting the driven gear, wherein the end portion of the drive shaft (4a; 4b) is pushed in a predetermined direction by working fluid supplied to the drive-side space, and the end portion of the idler shaft (5a; 5b) is pushed in the predetermined direction by working fluid supplied to the idler-side space, characterized in further comprising: a drive-side opening closing member configured so that when the pressure in the drive-side space is not higher than a drive-side intermediate pressure, which is lower than a pressure in the high-pressure space (18b; 118b; 218b), fluid communication between the drive-side space and the low-pressure space (18a, 18c; 118a, 118c; 218a; 318a) is not allowed, and when the pressure in the drive-side space exceeds the drive-side intermediate pressure, fluid communication between the drive-side space and the low-pressure space (18a, 18c; 118a, 118c; 218a; 318a) is allowed; and an idler-side opening closing member configured so that when the pressure in the idler-side space is not higher than an idler-side intermediate pressure, which is lower than the pressure in the high-pressure space (18b; 118b; 218b), fluid communication between the idler-side space and the low-pressure space (18a, 18c; 118a, 118c; 218a; 318a) is not allowed, and when the pressure in the idler-side space exceeds the idler-side intermediate pressure, fluid communication between the idler-side space and the low-pressure space (18a, 18c; 118a, 118c; 218a; 318a) is allowed. a drive-side opening closing member configured so that when the pressure in the drive-side space is not higher than a drive-side intermediate pressure, which is lower than a pressure in the high-pressure space (18b; 118b; 218b), fluid communication between the drive-side space and the low-pressure space (18a, 18c; 118a, 118c; 218a; 318a) is not allowed, and when the pressure in the drive-side space exceeds the drive-side intermediate pressure, fluid communication between the drive-side space and the low-pressure space (18a, 18c; 118a, 118c; 218a; 318a) is allowed; and an idler-side opening closing member configured so that when the pressure in the idler-side space is not higher than an idler-side intermediate pressure, which is lower than the pressure in the high-pressure space (18b; 118b; 218b), fluid communication between the idler-side space and the low-pressure space (18a, 18c; 118a, 118c; 218a; 318a) is not allowed, and when the pressure in the idler-side space exceeds the idler-side intermediate pressure, fluid communication between the idler-side space and the low-pressure space (18a, 18c; 118a, 118c; 218a; 318a) is allowed.