Flight Crew Commercial; Flight Crew Multiengine; Flight Crew Instrument
Flight Crew Last 90 Days 5; Flight Crew Total 3800; Flight Crew Type 250
Situational Awareness
Airspace Violation All Types; Conflict Airborne Conflict; Deviation / Discrepancy - Procedural FAR; Deviation / Discrepancy - Procedural Published Material / Policy
Flight Crew Exited Penetrated Airspace
Human Factors; Airspace Structure
I was transiting from ZZZ1 to ZZZ; VFR;  beneath Class B at 1000 ft and circumventing ZZZ2 [military] Class D airspace to the southeast; when I got a traffic alert.  I spotted a C130 to my right; about 500 feet above and 2000-3000 feet horizontally.  In watching him and turning out of his path; I inadvertently climbed to 1260 feet; into the Class B airspace.  I immediately descended back into unrestricted airspace.
Single pilot reported an inadvertent airspace violation which maneuvering to avoid other traffic.