Static vs. BGP Routes

General rule of routing: A static route will always override a route learned from a routing protocol (i.e. OSPF, BGP, etc…).
Or so I thought (and everyone I have spoken to lately)…

I recently had an issue with a Foundry BigIron router where a routing loop was occurring between my router and the upstream ISPs router. To give a basic synopsis there is a downstream customer that is peering with different ISPs via BGP. This customer is purchasing transport via an upstream connection connected to this BigIron. Because the customer is not in a BGP session with the Foundry router there are static routes pointing to the customer’s subnets via their cross connected interface.
When a new BGP peer was established from the Foundry all of a sudden traffic destined to the customer was bouncing between the Foundry and the upstream ISP. What happened?
The static routes to the customer were defined by the network address (/23 and larger subnets), the customer is advertising their network addresses as /24 subnets to their BGP peers to help with route dampening. When the Foundry BigIron re-calculated its routing table it found two routes to the same location. When this happens and the cost and administrative distances are the same the more specific route was given preference. However because the more specific route went back to the upstream ISP which then in turn tried to pass the traffic back through the Foundry to the customer a routing loop was created.
Solution? Either make the static routes more specific by modifying them to /24 networks, or create a prefix-list to filter out the route from the BGP peers. Given the amount of /24 networks that would be involved the prefix-list was chosen.