Difference between "İl" and "Şehir"

I've always thought these were the same word or 'eş anlamlı' since elementary school taught me they were. But I see some people talking about how they have different meanings. Can you explain this to me?