Arthur C. Clarke once said that sufficiently advanced science--too advanced to understand, that is to say--is indistinguishable from magic.
I think religion's relationship to magic is that it must be science that is too advanced for the believer, though not necessarily for the scientific community at large.