The advice about glass is becoming less important as the quality of lenses increases. The kit lenses for both cameras are pretty nice, and both brands offer inexpensive prime lenses (40mm, 50mm, and 85mm for Canon; 35mm, 50mm, and 85mm for Nikon), that are all as good or better than any professional zoom at equivalent focal lengths. And if you must have a zoom, 3d party zooms offered for both brands are great. I have the Sigma 8-16mm and 17-50mm, and Tamron 70-300mm. The Sigma lenses are superb, and Tamron is excellent through 200mm. These lenses are all significantly less expensive than professional-grade equivalent lenses. So, asking which camera is better is actually a legitimate question.
The D5100 has greater dynamic range, so you have the potential to get the shot in difficult conditions. Moreover, the D5100 performs slightly better at high ISO, so you will be able get better IQ when shooting in low-light situations.
Now, these factors are only relevant if the photographer shoots "Raw" and is prepared to spend time tweaking his shots on a computer using high quality software.
If instead your shoot jpg, or simply don't like working on shots after you've taken them, then the advantage flips to Canon. Canon has improved its jpeg engine with each and every new camera introduction. The out-of-camera results possible from Canon are truly amazing especially in low-light situations.
Therefore, the decision should be based on how you shoot. Look at samples on the web from each camera and see which ones you prefer. Some prefer Canon colors and processing. They argue that Canon skin tones are more realistic. However, I tend to believe Nikon does a better job with dark skintones (which I shoot more of) than Canon does. Moreover, Canon shots tend to be more contrasty, which may be desirable when shooting landscapes, but for those of us over 40, we look better with less contrast.
It is indeed complicated. Both cameras are excellent. One piece of common wisdom that I do subscribe to is that if you have friends and family that use one brand, then seriously consider buying into that family. Even if they are unwilling to share their equipment with you, you will be able to take advantage of their knowledge and experience.
Agreeing with R. Carr, you can't compare the two without comparing equivalent glass. . . Pixel peeping on the sample images, the D5100 does beat it on noise performance on ISO matters, but the glass makes all the difference. If you're going for purely iq, go with what you have glass for.