The school at which you got your undergraduate degree plays a huge role in your competitiveness on the grad school market. It is hard to give specific advice without knowing what country you are talking about, but purely numerically, for the vast majority of all countries worldwide, having top results and top references from the best university in that country will not get you into any of the top US or UK universities. The gulf between the undergrad programmes can be gigantic, and in some places you will just not develop your potential, almost regardless of how talented you are.
As I say, it is hard to be more specific without more information. Certainly, league tables mean almost nothing, and there are countries whose universities don't feature in league tables but offer solid education. If you live in such a country, then you are still relying on your grad admissions committee knowing it.
Edit: I have seen extremely strong students from Romania doing their undergraduate at top European universities (specifically in mathematics), and then getting into top Ph.D. programs in Europe; I do not recall having seen graduate students at top universities who did their undergraduate in Romania. That by itself does not mean much, after all it is a very small sample anyway.
If I read in a reference letter for a graduate programme that somebody was in the top 10% of their cohort at Bucharest, I would take that endorsement seriously. On the other hand, if you study there, you will have to be aware that the students that you see around you will not be representative of the competition that you will be facing when applying for the top graduate programmes, while if you are at Cambridge, or Bonn, say, then the best in your year are likely to actually be the primary candidates for the best Ph.D. programmes.
My view is that the main advantage of studying at the top places is not necessarily that they objectively offer the best education, but that you will be surrounded by very hard working and ambitious students, and that in turn will push you to develop your own full potential. If you manage to surround yourself with such a peer group at your university of choice in Romania, you will be fine. It's just that at the top places you will not have to look very hard to find such people. On the other hand Cambridge, say, is a much more expensive option than Bucharest. If you have the money, I would go for it; if not, then don't worry and just go to a top programme in Romania.