TCP works by dividing data into packets, assigning them unique identifiers and sequence numbers. It establishes a connection between the sender and receiver and ensures that data packets are delivered in the correct order. TCP also performs error checking to guarantee data integrity.