Granular materials react to shear stresses differently than do ordinary fluids. Rather than deforming uniformly, materials such as dry sand or cohesionless powders develop shear bands: narrow zones containing large relative particle motion leaving adjacent regions essentially rigid[1,2,3,4,5]. Since shear bands mark areas of flow, material failure and energy dissipation, they play a crucial role for many industrial, civil engineering and geophysical processes[6]. They also appear in related contexts, such as in lubricating fluids confined to ultra-thin molecular layers[7]. Detailed information on motion within a shear band in a three-dimensional geometry, including the degree of particle rotation and inter-particle slip, is lacking. Similarly, only little is known about how properties of the individual grains - their microstructure - affect movement in densely packed material[5]. Combining magnetic resonance imaging, x-ray tomography, and high-speed video particle tracking, we obtain the local steady-state particle velocity, rotation and packing density for shear flow in a three-dimensional Couette geometry. We find that key characteristics of the granular microstructure determine the shape of the velocity profile.