path-vector routing
Imagine asking for directions and, instead of just being told "it's 30 minutes away," you are handed the exact list of towns you'll drive through: "go through Springfield, then Riverton, then arrive." Path-vector routing is the directions-with-the-full-itinerary approach. Each route advertisement carries not a distance, but the entire ordered list of networks the route passes through. BGP is the path-vector protocol of the Internet.
Compare it with the two classic intra-domain families. Distance-vector routing (like RIP) tells neighbours only a distance — "I can reach X in 4 hops" — which is compact but can spin into the count-to-infinity problem when a link fails, because nobody can see the actual path. Link-state routing (like OSPF) floods full maps, which is precise but assumes everyone trusts everyone and shares topology. Path-vector keeps distance-vector's habit of only telling your neighbours (no flooding the whole world), but upgrades the message: instead of a bare number you advertise the full AS path. This buys two big things at once.
First, loop prevention is automatic and immediate: before accepting a route, an AS checks whether its own AS number already appears in the path; if it does, the route would form a loop, so it is rejected — no count-to-infinity. Second, policy becomes possible: because you can SEE which networks a route traverses, you can prefer, reject, or filter routes based on who is on the path, which is exactly what inter-domain routing needs, since the choice is about business relationships, not just hop counts.
AS C receives a route to prefix P with AS path [B, A]. Before C re-advertises it to AS D, it prepends its own number: the path becomes [C, B, A]. If a confused advertisement later comes back to C carrying [..., C, ...], C sees its own number already in the path, knows accepting it would create a loop, and silently discards it.
Carrying the whole path lets a router reject any route that already contains its own AS — instant loop detection.
Path-vector prevents routing loops by AS, but it does not make routing fast or optimal — and it cannot prove the path is true, which is why route hijacks (advertising a path you don't really have) work.