Small Aircraft
Flight Crew Flight Instructor; Flight Crew Commercial
Situational Awareness
ATC Issue All Types; Conflict NMAC; Deviation - Altitude Excursion From Assigned Altitude; Deviation / Discrepancy - Procedural Published Material / Policy; Deviation / Discrepancy - Procedural Clearance
Flight Crew Took Evasive Action
Human Factors
Flight crew was returning to ZZZ from a dual training flight. We were entering the ZZZ airspace and informed to fly southbound outside the pattern at landmark. We flew south until about a half mile south of Highway. At this point Tower cleared us to turn right and enter the downwind. Shortly after; Tower cleared Aircraft Y; (who was on the upwind for Runway XXL); to enter a left crosswind. At this time the student had controls of the aircraft and initiated approximately a 30 degree bank to enter the downwind. I noted that we were entering the downwind at approximately the correct distance from the runway. About half way through our 180 degree turn I checked the MFD and saw an aircraft climbing and turning towards us. Immediately after we received a TA annunciation. It took about 1 second to recognize the conflict; however. I shortly took controls of the aircraft. I then initiated a steep right turn while simultaneously applying full power for a high pitch up climb. The maneuver was so aggressive the stall horn sounded. We climbed about 400 feet to about 2;100 MSL at which point I leveled off and returned controls to my student. At the same time Aircraft Y initiated a hard right turn back to a southern heading. After the conflict was absolved both crews contacted Tower to confirm that we had been cleared for our respective turns. Tower confirmed that we had. We landed the plane without further incident. After reviewing Flightradar24 after the incident; we noted that at our closest point; we were at the same altitude; flying head-on in opposite directions; and less than a half mile from each other at our closest point.This event was caused by Tower issuing crosswind clearance to Aircraft Y shortly after clearing us for the downwind; while Aircraft Y was still behind us. A contributing factor may have been the strong winds aloft which rapidly pushed us into the downwind. Additional contributing factor was that I was complacent about the clearances granted by Tower and was not thinking of conflicts that may occur due to an ATC clearance. This caused me to not react to the conflict until we were very near to each other and received a TA. Being more vigilant about listening to ATC clearances and how they may create conflicts. Recognizing conflicts earlier so a resolution doesn't have to be as aggressive.
GA Flight Instructor reported a NMAC occurred while climbing out after takeoff.