An electric compressor comprising: a casing that is a cylindrical member having a bottom face at one end and an opening at the other end, and being provided with an inner circumferential surface of the cylinder, a first side-face rib having a first inner circumference which projects in a rib shape towards the central axis of the casing from the inner circumferential surface, and a second side-face rib having a second inner circumference which projects in a rib shape toward a central axis of the casing from the inner circumferential surface and whose radius is larger than the first inner circumference, the inner circumferential surface having an inclination that becomes more distant from the central axis of the casing from the bottom face toward the opening; a compressing unit that compresses fluid; and a motor unit including a rotor and a stator that rotationally drive the compressing unit, wherein cylindrical insertion surfaces are respectively disposed closer to the opening than the first inner circumference on the first side-face rib and closer to the opening than the second inner circumference on the second side-face rib, radiuses of the cylindrical insertion surfaces are larger than the second inner circumference in a cross section perpendicular to the central axis of the casing and in which the stator is accommodated; an enlarged diameter portion is disposed closer to the opening than the cylindrical insertion surfaces on the first side-face rib and makes the distance from the opening-side end of the cylindrical insertion surface to the opening equal, the radius of the enlarged diameter portion is larger than that of the cylindrical insertion surface; and an end at the opening side of the second inner circumference is located closer to the bottom face than an end at the opening side of the first inner circumference. a casing that is a cylindrical member having a bottom face at one end and an opening at the other end, and being provided with an inner circumferential surface of the cylinder, a first side-face rib having a first inner circumference which projects in a rib shape towards the central axis of the casing from the inner circumferential surface, and a second side-face rib having a second inner circumference which projects in a rib shape toward a central axis of the casing from the inner circumferential surface and whose radius is larger than the first inner circumference, the inner circumferential surface having an inclination that becomes more distant from the central axis of the casing from the bottom face toward the opening; a compressing unit that compresses fluid; and a motor unit including a rotor and a stator that rotationally drive the compressing unit, wherein cylindrical insertion surfaces are respectively disposed closer to the opening than the first inner circumference on the first side-face rib and closer to the opening than the second inner circumference on the second side-face rib, radiuses of the cylindrical insertion surfaces are larger than the second inner circumference in a cross section perpendicular to the central axis of the casing and in which the stator is accommodated; an enlarged diameter portion is disposed closer to the opening than the cylindrical insertion surfaces on the first side-face rib and makes the distance from the opening-side end of the cylindrical insertion surface to the opening equal, the radius of the enlarged diameter portion is larger than that of the cylindrical insertion surface; and an end at the opening side of the second inner circumference is located closer to the bottom face than an end at the opening side of the first inner circumference.