BGP is the exterior gateway protocol that connects different autonomous systems on the internet. It allows for the exchange of routing and reachability information between these systems. BGP operates using a finite state machine to manage the states of connections between peers. It establishes TCP connections between routers to exchange routing updates and keep connections alive through regular keepalive messages. BGP version 4, defined in RFC 4271, is the current standard implementation which supports features like classless inter-domain routing and route aggregation.