We determine the order of magnitude of H(x,y,z), the number of integers n≤x having a divisor in (y,z], for all x,y and z. We also study Hr(x,y,z), the number of integers n≤x having exactly r divisors in (y,z]. When r=1 we establish the order of magnitude of H1(x,y,z) for all x,y,z satisfying z≤x1/2−ε. For every r≥2, C>1 and ε>0, we determine the order of magnitude of Hr(x,y,z) uniformly for y large and y+y/(logy)log4−1–ε≤z≤min(yC,x1/2−ε). As a consequence of these bounds, we settle a 1960 conjecture of Erdős and some conjectures of Tenenbaum. One key element of the proofs is a new result on the distribution of uniform order statistics.