C172 Flight Instructor reported ATC issuing incorrect pattern instructions resulted in confusion and a NMAC situation.
Synopsis
C172 Flight Instructor reported ATC issuing incorrect pattern instructions resulted in confusion and a NMAC situation.
Narrative
My student and I were coming into ZZZ from the north. We made a call to the tower at 6 Miles. The tower instructed us to enter the left base for runway XX and report 3 miles. Another aircraft was also approaching from the west; approximately 8 miles away at that time. When my student and I called at 3 miles; we were given clearance ' runway XX cleared for touch and go make left traffic after report downwind.' about 3 minutes later the aircraft approching from the west made a call 'ZZZ tower Aircraft Y 3 miles on the right down wind for runway XX' ZZZ tower responds ' Aircraft Y report right downwind for runway XY'. My student and I were on short final for runway XX when I noticed that instructions from the tower would put us on a collision course. I thought the tower had Aircraft Y in sight and was giving them the right downwind for XY to account for spacing. As my student completed a touch and go; we rotated; and about 50 ft AGL; I saw Aircraft Y at my 11 o'clock on the downwind for runway XY; as instructed. I took control at this time; realizing that the tower had given the wrong instructions to Aircraft Y. I kept flying runway heading; expecting the tower to see the mistake; but Aircraft Y turned right base for runway XY and was heading on a direct intercept course for my student and me. I then disregarded the tower's instructions and made a right turn to the south to avoid a certain collision. I then proceeded to enter the right downwind for runway XX. Aircraft Y; while on final for runway XY; proceeded to execute a go-around. The tower instructed Aircraft Y to make a left turn to enter the right downwind for runway XX. When my student and I heard the tower make this call; we executed a left turn to avoid Aircraft Y since they were put on another collision course. At this time; we had a 1/4 mile separation with Aircraft Y closest to the airport. I extended the right downwind so Aircraft Y could land without conflict. The tower then issued my student and me a landing clearance to land runway XX and number two to the airport.Overall; if I had followed the tower's instructions; we would have had a mid-air collision; and we had to take evasive action twice. I fear that if I had a student solo in the same conditions; the outcome would have been very different.
Source: NASA Aviation Safety Reporting System (public domain). Reports are voluntary submissions and are not verified by NASA.