A motor-driven compressor comprising: a compression mechanism compressing a refrigerant gas; a rotary shaft rotating to drive the compression mechanism; an electric motor connected to the rotary shaft; a motor drive circuit for driving the electric motor, the motor drive circuit having a plurality of electronic components; a connecting terminal electrically connected the electric motor to the motor drive circuit; and a housing assembly in which the compression mechanism, the electric motor and the motor drive circuit are disposed along the axial direction of the rotary shaft, the housing assembly has a first housing used for mounting the electric motor and the compression mechanism, and having a cylindrical shape with one end covered and a fastening portion (121 D, 12E) at the radially peripheral portion of the first housing, characterized in that a second housing having a terminal mounting portion for fixing the connecting terminal and a fastening portion (13A, 13E) at the radially peripheral portion of the second housing, and thermally coupled to the electric component of the motor drive circuit, and a third housing having a cylindrical shape with one end closed, and joined to the second housing to form an accommodation space for accommodating the motor drive circuit, and in that a closed casing is formed by fastening the fastening portion (13A, 13E) of the second housing to the fastening portion (121 D, 12E) of the first housing by means of a first bolt, and connecting the second housing to the open end of the first housing, wherein the first housing is joined to the second housing, and the second housing is joined to the third housing. a compression mechanism compressing a refrigerant gas; a rotary shaft rotating to drive the compression mechanism; an electric motor connected to the rotary shaft; a motor drive circuit for driving the electric motor, the motor drive circuit having a plurality of electronic components; a connecting terminal electrically connected the electric motor to the motor drive circuit; and a housing assembly in which the compression mechanism, the electric motor and the motor drive circuit are disposed along the axial direction of the rotary shaft, the housing assembly has a first housing used for mounting the electric motor and the compression mechanism, and having a cylindrical shape with one end covered and a fastening portion (121 D, 12E) at the radially peripheral portion of the first housing, characterized in that a second housing having a terminal mounting portion for fixing the connecting terminal and a fastening portion (13A, 13E) at the radially peripheral portion of the second housing, and thermally coupled to the electric component of the motor drive circuit, and a third housing having a cylindrical shape with one end closed, and joined to the second housing to form an accommodation space for accommodating the motor drive circuit, and in that a closed casing is formed by fastening the fastening portion (13A, 13E) of the second housing to the fastening portion (121 D, 12E) of the first housing by means of a first bolt, and connecting the second housing to the open end of the first housing, wherein the first housing is joined to the second housing, and the second housing is joined to the third housing.