A main spindle unit (30, M) for being attached to a unit support table which supports a first end of a tool (Th) or for being fixed to a head of a machine tool, such that the tool (Th, T) is able to rotate about an axis (Am), the main spindle unit holding a second end of the tool (Th, T) to rotate the tool about the axis (Am) and comprising: a main spindle (31, 131) which extends in an axial direction, in which the axis (Am) extends, about the axis (Am); a motor rotor (37, 137) which is fixed to an outer periphery of the main spindle (31, 131); a motor stator (39, 139) which is disposed on an outer periphery of the motor rotor (37, 137); a holder (35, 135) which is provided on a front side which is one end side of the main spindle (31, 131) in the axial direction and holds the tool (Th, T); a front bearing (41, 141) which is disposed on the front side of the motor rotor (37, 137)and on a rear side of the holder (35, 135), the rear side being a side opposite to the front side, and rotatably supports the main spindle (31, 131); a rear bearing (43, 143) which is disposed on the rear side of the motor rotor (37, 137)and rotatably supports the main spindle (31, 131); a motor case (51, 151) which has a tubular shape about the axis (Am) and in which the motor stator (39, 139) is fixed to an inner peripheral surface thereof; a front case (61,161) which covers an outer periphery of the front bearing (41, 141); and a rear case (71,171) which covers an outer periphery of the rear bearing (43, 143), characterized in that the front case (61,161) has a front body portion (62, 162) which covers the outer periphery of the front bearing (41, 141)to hold the front bearing (41, 141) and a front flange portion (64,164) which extends radially outward with respect to the axis (Am) from an outer periphery of the front body portion (62, 162), wherein the rear case (71,171) has a rear body portion (72, 172) which covers an outer periphery of the rear bearing (43, 143)to hold the rear bearing (43, 143)and a rear flange portion (74, 174) which extends radially outward from an outer periphery of the rear body portion (72, 172), wherein an outer diameter of the front body portion (62, 162) is smaller than an inner diameter of the motor case (51, 151), wherein in the front flange portion (64,164), a front mounted surface (65, 165) which is able to come into contact with a first mounting surface (24, 124) of the unit support table or the fixing frame facing the rear side and a contact surface (67, 167) which is in contact with the motor case are formed so as to face the front side, wherein an outer diameter of the rear flange portion (74, 174)is larger than an outer diameter of the motor case (51, 151), and wherein in the rear flange portion (74, 174), a rear mounted surface (75,175) which is in contact with a second mounting surface (73,173) of the unit support table or the fixing frame facing the rear side is formed so as to face the front side. a main spindle (31, 131) which extends in an axial direction, in which the axis (Am) extends, about the axis (Am); a motor rotor (37, 137) which is fixed to an outer periphery of the main spindle (31, 131); a motor stator (39, 139) which is disposed on an outer periphery of the motor rotor (37, 137); a holder (35, 135) which is provided on a front side which is one end side of the main spindle (31, 131) in the axial direction and holds the tool (Th, T); a front bearing (41, 141) which is disposed on the front side of the motor rotor (37, 137)and on a rear side of the holder (35, 135), the rear side being a side opposite to the front side, and rotatably supports the main spindle (31, 131); a rear bearing (43, 143) which is disposed on the rear side of the motor rotor (37, 137)and rotatably supports the main spindle (31, 131); a motor case (51, 151) which has a tubular shape about the axis (Am) and in which the motor stator (39, 139) is fixed to an inner peripheral surface thereof; a front case (61,161) which covers an outer periphery of the front bearing (41, 141); and a rear case (71,171) which covers an outer periphery of the rear bearing (43, 143), the front case (61,161) has a front body portion (62, 162) which covers the outer periphery of the front bearing (41, 141)to hold the front bearing (41, 141) and a front flange portion (64,164) which extends radially outward with respect to the axis (Am) from an outer periphery of the front body portion (62, 162), wherein the rear case (71,171) has a rear body portion (72, 172) which covers an outer periphery of the rear bearing (43, 143)to hold the rear bearing (43, 143)and a rear flange portion (74, 174) which extends radially outward from an outer periphery of the rear body portion (72, 172), wherein an outer diameter of the front body portion (62, 162) is smaller than an inner diameter of the motor case (51, 151), wherein in the front flange portion (64,164), a front mounted surface (65, 165) which is able to come into contact with a first mounting surface (24, 124) of the unit support table or the fixing frame facing the rear side and a contact surface (67, 167) which is in contact with the motor case are formed so as to face the front side, wherein an outer diameter of the rear flange portion (74, 174)is larger than an outer diameter of the motor case (51, 151), and wherein in the rear flange portion (74, 174), a rear mounted surface (75,175) which is in contact with a second mounting surface (73,173) of the unit support table or the fixing frame facing the rear side is formed so as to face the front side.