A heat exchanger comprising a first heat exchange unit and a second heat exchange unit disposed one above the other, - the first heat exchange unit and the second heat exchange unit each having a heat transfer pipe group configured such that a plurality of heat transfer pipes, extending in a first orientation, through which refrigerant flows, are arranged in parallel in a second orientation orthogonal to the first orientation, the heat transfer pipe groups of each of the first heat exchange unit (3 a) and the second heat exchange unit being arranged in at least two rows in a third orientation, the first orientation being an up-and-down direction, the third orientation being a flow direction of air along a horizontal direction, - wherein the heat transfer pipe groups include a first heat transfer pipe group on a windward side of the first heat exchange unit (3 a), a second heat transfer pipe group on a leeward side of the first heat exchange unit (3 a), a third heat transfer pipe group on a windward side of the second heat exchange unit, and a fourth heat transfer pipe group on a leeward side of the second heat exchange unit, and wherein the heat exchanger includes an intermediate header unit through which a lower end of the first heat transfer pipe group and a lower end of the second heat transfer pipe group communicate with an upper end of the third heat transfer pipe group and an upper end of the fourth heat transfer pipe group, - in a case where the heat exchanger functions as a condenser, the intermediate header unit causing at least a portion of refrigerant having flowed downward through the first heat transfer pipe group and flowed out through the lower end of the first heat transfer pipe group to flow in through the upper end of the fourth heat transfer pipe group and flow downward through the fourth heat transfer pipe group and causing at least a portion of refrigerant having flowed downward through the second heat transfer pipe group and flowed out through the lower end of the second heat transfer pipe group to flow in through the upper end of the third heat transfer pipe group or the upper end of the fourth heat transfer pipe group and flow downward through the third heat transfer pipe group or the fourth heat transfer pipe group. - the first heat exchange unit and the second heat exchange unit each having a heat transfer pipe group configured such that a plurality of heat transfer pipes, extending in a first orientation, through which refrigerant flows, are arranged in parallel in a second orientation orthogonal to the first orientation, the heat transfer pipe groups of each of the first heat exchange unit (3 a) and the second heat exchange unit being arranged in at least two rows in a third orientation, the first orientation being an up-and-down direction, the third orientation being a flow direction of air along a horizontal direction, - wherein the heat transfer pipe groups include a first heat transfer pipe group on a windward side of the first heat exchange unit (3 a), a second heat transfer pipe group on a leeward side of the first heat exchange unit (3 a), a third heat transfer pipe group on a windward side of the second heat exchange unit, and a fourth heat transfer pipe group on a leeward side of the second heat exchange unit, and wherein the heat exchanger includes an intermediate header unit through which a lower end of the first heat transfer pipe group and a lower end of the second heat transfer pipe group communicate with an upper end of the third heat transfer pipe group and an upper end of the fourth heat transfer pipe group, - in a case where the heat exchanger functions as a condenser, the intermediate header unit causing at least a portion of refrigerant having flowed downward through the first heat transfer pipe group and flowed out through the lower end of the first heat transfer pipe group to flow in through the upper end of the fourth heat transfer pipe group and flow downward through the fourth heat transfer pipe group and causing at least a portion of refrigerant having flowed downward through the second heat transfer pipe group and flowed out through the lower end of the second heat transfer pipe group to flow in through the upper end of the third heat transfer pipe group or the upper end of the fourth heat transfer pipe group and flow downward through the third heat transfer pipe group or the fourth heat transfer pipe group.