We combine ab initio density functional theory with transport calculations to provide a microscopic basis for distinguishing between good and poor metal contacts to nanotubes. Comparing Ti and Pd as examples of different contact metals, we trace back the observed superiority of Pd to the nature of the metal-nanotube hybridization. Based on large scale Landauer transport calculations, we suggest that the `optimum metal-nanotube contact combines a weak hybridization with a large contact length between the metal and the nanotube.