Megaproject Social Responsibility (MSR) is widely acknowledged as contributing to project performance. However, the effect of Megaproject Social Responsibility Behavior (MSRB) implemented by organizations participating in construction on project performance remains a subject of considerable debate, and the intrinsic mechanism of MSRB’s effect on the performance of megaprojects has not been elucidated. Therefore, this study employs resource-based theory to investigate the mechanism underlying MSRB’s effect on project performance, taking into account both internal and external social capital as well as resource integration capacity as pivotal influences. Drawing on sample data from 206 experienced project managers across the various parties involved, this study develops a Bayesian network model to elucidate the MSRB effect mechanism. Through inference and sensitivity analysis, this study discovers variations in the enhancement effects across the four dimensions of MSRB on project performance. Notably, a combination strategy yields superior enhancement effects. Furthermore, when project performance is suboptimal, resource integration capacity emerges as a significant mediator between MSRB and project performance. Conversely, at high levels of project performance, MSRB directly contributes to enhancing project outcomes. The findings of this study offer valuable insights for the governance of MSR and the enhancement of project performance in megaprojects.