BGP assigns the first valid path as the current best path. BGP then compares the best path with the next path in the list, until BGP reaches the end of the list of valid paths. This list provides the rules that are used to determine the best path:
Prefer the path with the highest WEIGHT.
Prefer the path with the highest LOCAL_PREF.
Prefer the path that was locally originated via a network or aggregate BGP subcommand or through redistribution from an IGP.
Prefer the path with the shortest AS_PATH
Prefer the path with the lowest origin type.
Prefer the path with the lowest multi-exit discriminator (MED).
Prefer eBGP over iBGP paths.
Prefer the path with the lowest IGP metric to the BGP next hop.
When both paths are external, prefer the path that was received first (the oldest one).
Prefer the route that comes from the BGP router with the lowest router ID.
If the originator or router ID is the same for multiple paths, prefer the path with the minimum cluster list length.
Prefer the path that comes from the lowest neighbor address.
Adam, Paul (2014-07-12). All-in-One CCIE V5 Written Exam Guide (Kindle Locations 3910-3921). . Kindle Edition.