PA-28 Cherokee/Archer/Dakota/Pillan/Warrior
Flight Crew Instrument; Flight Crew Flight Instructor; Flight Crew Commercial; Flight Crew Multiengine
Flight Crew Last 90 Days 173.9; Flight Crew Total 1022.7
Communication Breakdown; Time Pressure
ATC Issue All Types; Conflict NMAC; Deviation - Altitude Excursion From Assigned Altitude; Deviation / Discrepancy - Procedural Clearance
Flight Crew Took Evasive Action
Human Factors
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.
PA-28 Instructor reported an NMAC event while complying with ATC departure instruction.