STP is a self-configuring Layer 2 algorithm that's responsible for removing loops in a switched network while still providing path redundancy. Because a switch automatically forwards broadcasts and multicasts, STP is necessary to make sure that this traffic is not continuously forwarded throughout a switched network. Another problem with loops is that with the switch's learning function, it might mistakenly update its address table with incorrect information concerning an end station as a frame traverses a loop.
STP was developed by DEC and later incorporated into IEEE's standards as 802.1D. However, the two protocols are not compatible. In a bridged or switched network, all Layer 2 devices must run the same STP algorithm.