We extend the celebrate global compactness result of Struwe (Math Z 187:511–517, 1984) to a class of critical nonlinear problems involving the spectral fractional Laplacian with mixed Dirichlet–Neumann boundary conditions. We study the behavior of the non-negative sequences failing the Palais–Smale condition for the energy functional associated with the problem: \(\begin{aligned} \left\{ \begin{array}{lll} (-\Delta )^s u =|u|^{\frac{4s}{n-2s}}u , \, \hspace{71.13188pt} \text{ in } \Omega ,\\ \\ \displaystyle \hspace{11.38092pt}\mathscr {B}(u) := 1_{\Gamma _0}u+1_{\Gamma _1}\dfrac{\partial u}{\partial \nu }=0 \hspace{11.38092pt} \text{ on } \partial \Omega ,\\ \end{array} \right. \end{aligned}\) where \(s\in (1/2,1)\) and \(\Omega \subset \mathbb {R}^n, n\ge 2\) , is a bounded domain whose boundary \(\partial \Omega \) is decomposed into two closed parts \(\overline{\Gamma }_0\) and \(\overline{\Gamma }_1\) . The main theorem of this paper provides, under condition (H) below, an accurate description of any non-convergent Palais–Smale sequence, showing that it converges weakly to a critical point plus a finite sum of “bubbles” that capture the energy loss and concentrate at points in \(\Omega \cup \Gamma _1\) .