A heat exchanger, comprising: a plurality of flat tubes arranged one above the other; fins connected to the flat tubes; a first header collecting pipe in which one end of each of the plurality of flat tubes is inserted; and a second header collecting pipe in which the other end of each of the plurality of flat tubes is inserted, the heat exchanger being configured to exchange heat between a fluid flowing through the flat tubes and air outside the flat tubes, wherein each of the first and second header collecting pipes (40, 70) extends in a vertical direction, and includes at least one communication space which communicates with the plurality of flat tubes, the communication spaces include an upstream communication space (75a-75f) which communicates with an upstream side of the plurality of flat tubes when the heat exchanger functions as an evaporator, the upstream communication space (75a-75f) is provided with a partition plate which extends in the vertical direction and divides the upstream communication space (75a-75f) into a first space that communicates with the plurality of flat tubes and a second space that communicates with an inlet portion configured to introduce a refrigerant into the upstream communication space (75a-75f) when the heat exchanger functions as an evaporator, and a communication path allowing the first space and the second space to communicate with each other is formed at a lower portion of the upstream communication space (75a-75f), wherein the communication path is a through hole formed in a lower portion of the partition plate or a gap formed between a lower edge of the partition plate and a bottom surface of the communication space (75a-75f), and the heat exchanger being characterized in that a division plate which divides the second space into an upper space and a lower space is provided at a lower portion of the upstream communication space (75a-75f) above the inlet portion and the communication path, the division plate divides the first space into an upper space and a lower space, and the division plate has a first portion closer to the first space provided with two openings (92b, 92b), which allow the upper space and the lower space of the first space above and below the division plate to communicate with each other. a plurality of flat tubes arranged one above the other; fins connected to the flat tubes; a first header collecting pipe in which one end of each of the plurality of flat tubes is inserted; and a second header collecting pipe in which the other end of each of the plurality of flat tubes is inserted, the heat exchanger being configured to exchange heat between a fluid flowing through the flat tubes and air outside the flat tubes, wherein each of the first and second header collecting pipes (40, 70) extends in a vertical direction, and includes at least one communication space which communicates with the plurality of flat tubes, the communication spaces include an upstream communication space (75a-75f) which communicates with an upstream side of the plurality of flat tubes when the heat exchanger functions as an evaporator, the upstream communication space (75a-75f) is provided with a partition plate which extends in the vertical direction and divides the upstream communication space (75a-75f) into a first space that communicates with the plurality of flat tubes and a second space that communicates with an inlet portion configured to introduce a refrigerant into the upstream communication space (75a-75f) when the heat exchanger functions as an evaporator, and a communication path allowing the first space and the second space to communicate with each other is formed at a lower portion of the upstream communication space (75a-75f), wherein the communication path is a through hole formed in a lower portion of the partition plate or a gap formed between a lower edge of the partition plate and a bottom surface of the communication space (75a-75f), and the heat exchanger being characterized in that a division plate which divides the second space into an upper space and a lower space is provided at a lower portion of the upstream communication space (75a-75f) above the inlet portion and the communication path, the division plate divides the first space into an upper space and a lower space, and the division plate has a first portion closer to the first space provided with two openings (92b, 92b), which allow the upper space and the lower space of the first space above and below the division plate to communicate with each other.