Narrative:

After taking off out of ZZZ; we changed back over to center after executing the published missed approach; as directed. When we switched over; center immediately called us to advise us of a pc-12 that was trying to get into ZZZ. Giving that we were in their way; I'm sure they were frustrated to be holding. Center asked if we could change plans and hold north. With a day two instrument student; I decided it would be best to just simply get our clearance to the next airport; being ZZZ1. The controller gave us a direct clearance and to maintain 4;000 ft. When activated; we began our turn and the student and I both spotted a multi engine climbing towards us. At this point we were at the same altitude with no separation; and the traffic was not reported to us before the amended clearance. With this; I told the student to climb; and climb fast. We climbed out of clearance 300 ft.; and provided ourselves the separation we needed not to collide with the multi-engine. This decision was made in the interest of safety and traffic avoidance. Even with us climbing out of clearance; we roughly only had 400-600 ft. Of clearance between us. After continuing on to ZZZ1; we were told 'possible pilot deviation' and to copy down a number. Once landed at ZZZ2; I called; and [name] apologized for what happened and after two supervisors reviewing the radar and audio; he believed we made the best decision; assuring us he was on our side; and told me he was happy we were safe. He also added that the reason the number was given; was for quality control of his center.

Google
 

Original NASA ASRS Text

Title: PA-28 Instructor reported an NMAC event while complying with ATC departure instruction.

Narrative: After taking off out of ZZZ; we changed back over to center after executing the published missed approach; as directed. When we switched over; center immediately called us to advise us of a PC-12 that was trying to get into ZZZ. Giving that we were in their way; I'm sure they were frustrated to be holding. Center asked if we could change plans and hold north. With a day two instrument student; I decided it would be best to just simply get our clearance to the next airport; being ZZZ1. The controller gave us a direct clearance and to maintain 4;000 ft. When activated; we began our turn and the student and I both spotted a multi engine climbing towards us. At this point we were at the same altitude with no separation; and the traffic was not reported to us before the amended clearance. With this; I told the student to climb; and climb fast. We climbed out of clearance 300 ft.; and provided ourselves the separation we needed not to collide with the multi-engine. This decision was made in the interest of safety and traffic avoidance. Even with us climbing out of clearance; we roughly only had 400-600 ft. of clearance between us. After continuing on to ZZZ1; we were told 'possible pilot deviation' and to copy down a number. Once landed at ZZZ2; I called; and [name] apologized for what happened and after two supervisors reviewing the radar and audio; he believed we made the best decision; assuring us he was on our side; and told me he was happy we were safe. He also added that the reason the number was given; was for quality control of his center.

Data retrieved from NASA's ASRS site and automatically converted to unabbreviated mixed upper/lowercase text. This report is for informational purposes with no guarantee of accuracy. See NASA's ASRS site for official report.