A heat exchanger comprising: a plurality of heat transfer tubes arranged in multiple columns along a predetermined direction; and a header (21, 24) configured to retain first longitudinal end portions of the heat transfer tubes, the header (21, 24) including: a first member (40, 110) including a main wall portion (41, 111) having a plurality of through holes (42, 112) through each of which the first longitudinal end portion of an associated one of the heat transfer tubes passes; a second member (50, 120) defining a plurality of insertion spaces (70, 160) that each communicate with the first longitudinal end portion of at least one of the heat transfer tubes; and a third member (60, 130) facing the first longitudinal end portions of the heat transfer tubes that have respectively passed through the through holes (42, 112), wherein the second member (50, 120) includes: a pair of side plates (51, 121) defining the insertion spaces (70, 160) therebetween in a width direction of the header (21, 24); and at least one partition plate (52, 122) connected to the pair of side plates (51, 121) to separate the insertion spaces (70, 160) from each other, characterized in that the pair of side plates and the at least one partition plate of the second member each have two end surfaces that are respectively in contact with the main wall portion of the first member and the third member. a plurality of heat transfer tubes arranged in multiple columns along a predetermined direction; and a header (21, 24) configured to retain first longitudinal end portions of the heat transfer tubes, the header (21, 24) including: a first member (40, 110) including a main wall portion (41, 111) having a plurality of through holes (42, 112) through each of which the first longitudinal end portion of an associated one of the heat transfer tubes passes; a second member (50, 120) defining a plurality of insertion spaces (70, 160) that each communicate with the first longitudinal end portion of at least one of the heat transfer tubes; and a third member (60, 130) facing the first longitudinal end portions of the heat transfer tubes that have respectively passed through the through holes (42, 112), wherein the second member (50, 120) includes: a pair of side plates (51, 121) defining the insertion spaces (70, 160) therebetween in a width direction of the header (21, 24); and at least one partition plate (52, 122) connected to the pair of side plates (51, 121) to separate the insertion spaces (70, 160) from each other, characterized in that the pair of side plates and the at least one partition plate of the second member each have two end surfaces that are respectively in contact with the main wall portion of the first member and the third member. a first member (40, 110) including a main wall portion (41, 111) having a plurality of through holes (42, 112) through each of which the first longitudinal end portion of an associated one of the heat transfer tubes passes; a second member (50, 120) defining a plurality of insertion spaces (70, 160) that each communicate with the first longitudinal end portion of at least one of the heat transfer tubes; and a third member (60, 130) facing the first longitudinal end portions of the heat transfer tubes that have respectively passed through the through holes (42, 112), wherein the second member (50, 120) includes: a pair of side plates (51, 121) defining the insertion spaces (70, 160) therebetween in a width direction of the header (21, 24); and at least one partition plate (52, 122) connected to the pair of side plates (51, 121) to separate the insertion spaces (70, 160) from each other, characterized in that the pair of side plates and the at least one partition plate of the second member each have two end surfaces that are respectively in contact with the main wall portion of the first member and the third member. a pair of side plates (51, 121) defining the insertion spaces (70, 160) therebetween in a width direction of the header (21, 24); and at least one partition plate (52, 122) connected to the pair of side plates (51, 121) to separate the insertion spaces (70, 160) from each other, characterized in that the pair of side plates and the at least one partition plate of the second member each have two end surfaces that are respectively in contact with the main wall portion of the first member and the third member.