In signed networks with simultaneous friendly and hostile interactions, there is a general tendency to a global structural balance, based on the dynamical model of links status. Although, the structural balance represents a state of the network with a lack of contentious situations, there are always tensions in real networks. To study such networks, we generalize the balance dynamics in nonzero temperatures. The presented model uses elements from Boltzmann-Gibbs statistical physics to assign an energy to each type of triad, and it introduces the temperature as a measure of tension tolerance of the network. Based on the mean-field solution of the model, we find out that the model undergoes a first-order phase transition from an imbalanced random state to structural balance with a critical temperature Tc, where in the case of T > Tc there is no chance to reach the balanced state. A main feature of the first-order phase transition is the occurrence of a hysteresis loop crossing the balanced and imbalanced regimes.