A heat exchanger (3, 3a) comprising: a heat exchange element including a plurality of flat tubes spaced from each other; and a first header in which one end portion of each of the plurality of flat tubes of the heat exchange element is inserted, wherein the first header includes a first main header portion in which some of the plurality of flat tubes are inserted, a first sub-header portion in which others of the plurality of flat tubes are inserted such that the number of the flat tubes inserted in the first sub-header portion is smaller than the number of the flat tubes inserted in the first main header portion, and a partition plate (33, 33a) provided between the first main header portion and the first sub-header portion, and joined to both the first main header portion and the first sub-header portion, and the partition plate has a surface area that is larger than a sectional area of the first main header portion and a sectional area of the first sub-header portion; characterized by the heat exchanger (3, 3a) further comprising a gas pipe connected to the first main header portion such that refrigerant flows out from the gas pipe when the heat exchanger operates as an evaporator, and refrigerant flows into the gas pipe when the heat exchanger operates as a condenser, wherein at least part of the gas pipe is located below the first sub-header portion and extends in a longitudinal direction thereof, and the partition plate includes an opening portion at a lower portion of the partition plate, the opening portion allowing the gas pipe to pass though the opening portion and supporting the gas pipe passing through the opening portion. a heat exchange element including a plurality of flat tubes spaced from each other; and a first header in which one end portion of each of the plurality of flat tubes of the heat exchange element is inserted, wherein the first header includes a first main header portion in which some of the plurality of flat tubes are inserted, a first sub-header portion in which others of the plurality of flat tubes are inserted such that the number of the flat tubes inserted in the first sub-header portion is smaller than the number of the flat tubes inserted in the first main header portion, and a partition plate (33, 33a) provided between the first main header portion and the first sub-header portion, and joined to both the first main header portion and the first sub-header portion, and a first main header portion in which some of the plurality of flat tubes are inserted, a first sub-header portion in which others of the plurality of flat tubes are inserted such that the number of the flat tubes inserted in the first sub-header portion is smaller than the number of the flat tubes inserted in the first main header portion, and a partition plate (33, 33a) provided between the first main header portion and the first sub-header portion, and joined to both the first main header portion and the first sub-header portion, and the partition plate has a surface area that is larger than a sectional area of the first main header portion and a sectional area of the first sub-header portion; characterized by the heat exchanger (3, 3a) further comprising a gas pipe connected to the first main header portion such that refrigerant flows out from the gas pipe when the heat exchanger operates as an evaporator, and refrigerant flows into the gas pipe when the heat exchanger operates as a condenser, wherein at least part of the gas pipe is located below the first sub-header portion and extends in a longitudinal direction thereof, and the partition plate includes an opening portion at a lower portion of the partition plate, the opening portion allowing the gas pipe to pass though the opening portion and supporting the gas pipe passing through the opening portion.