We study the gauge transformation of the recently computed one-loop four-point function of {cal N}=4 supersymmetric Yang-Mills theory with gauge group U(N). The contributions from nonplanar diagrams are not gauge invariant. We compute their gauge variation and show that it is cancelled by the variation from corresponding terms of the one-loop five-point function. This mechanism is general: it insures the gauge invariance of the noncommutative one-loop effective action.