Dynamic transitions between competition and cooperation are common in real-world intergroup interactions, yet prior research has typically examined competition or cooperation in isolation. This study explored how transitions between competition and cooperation influenced intergroup attitudes and the neural processes involved. Using functional Near-Infrared Spectroscopy (fNIRS) hyperscanning, we recorded brain activity from 69 dyads during interactions. Results showed that cooperation enhanced neural synchronization in the right temporoparietal junction (rTPJ), leading to more positive outgroup attitudes. In contrast, competition increased synchronization in the right dorsolateral prefrontal cortex (rDLPFC), correlating with decreased outgroup likability. The sequence of interactions was critical, with the first interaction exerting a carryover effect on the next. Cooperation buffered the negative effects of later competition, while competition weakened the positive effects of subsequent cooperation. These findings emphasized the importance of understanding dynamic intergroup interactions and highlighted the potential of cooperation to mitigate biases and improve intergroup relations.