Both are very good universities, so it comes to where you will be happy for three to four years.
I visited both and I didn't like Durham as much as St Andrews. Durham Uni is much bigger than St As and they are planning to expand further. I prefer the smaller, more personal, environment of St As. Also, my Dad comes from Durham and he told me - although nothing too bad - there used to be a little bit of friction between students and locals.
The college system at Durham is appealing but, unlike Oxbridge, Durham colleges don't get involved in teaching. I was really disappointed with some of the colleges as they seemed a small and bit run down. St As don't have colleges, but they do have halls which I expect provide the same kind of experience.
If you like sport, Durham is well known as a sporty university. Durham and St As both have lots of different societies.
I was initially put off by St As four year degrees but, after thinking about it, I realise it gives lots of flexibility and I particularly like the idea of studying two extra subjects in the first two years.
I wouldn't worry about rankings too much, both will provide well respected qualifications.
Both universities will provide a unique undergraduate experience, with different traditions, so you have to decide what course you prefer and where you'd be happy.