Using the particle swarm optimization algorithm, we conducted an extensive search for the high-pressure stable structure of technetium diboride (TcB2) within the pressure range of 0–400 GPa. At zero pressure, the P63/mmc (hP6-TcB2) structure is considered the ground state configuration. As the pressure increases, a structural transition from hP6-TcB2 to P6/mmm (hP3-TcB2) occurs at approximately 174.9 GPa. We discuss the bonding between the two distinct phases and analyze the contribution of different atomic bonds to maintaining their structural stability. Meanwhile, the temperature–pressure phase diagram of TcB2 was successfully determined for the first time through the quasi-harmonic approximation method. It is predicted that the transition pressure from hP6-TcB2 to hP3-TcB2 can be reduced to about 164 GPa at a room temperature of 300 K. These results provide valuable insights into the behavior of TcB2 under different temperature and pressure conditions and open up new possibilities for exploring its potential applications in a variety of environments.