Let X = (x 1 , . . . , x n ) be a vector of distinct positive integers. The n × n matrix S = S(X) := (gcd(x i , x j )) n i,j=1 , where gcd(x i , x j ) denotes the greatest common divisor of x i and x j , is called the greatest common divisor (GCD) matrix on X. By a surprising result of Beslin and Ligh [Linear Algebra and Appl. 118], all GCD matrices are positive definite. In this paper, we completely characterize the GCD matrices satisfying the stronger property of being totally nonnegative (TN) or totally positive (TP). As we show, a GCD matrix is never TP when n ≥ 3, and is TN if and only if it is T N 2 , i.e., all its 2 × 2 minors are nonnegative. We next demonstrate that a GCD matrix is TN 2 if and only if the exponents of each prime divisor in the prime factorization of the x i s form a monotonic sequence. Reformulated in the language of kernels, our results characterize the subsets of integers over which the kernel K(x, y) = gcd(x, y) is totally nonnegative. The proofs of our characterizations depend on Gantmacher and Krein's notion of a Green's matrix. We conclude by showing that a GCD matrix is TN if and only if it is a Green's matrix. As a consequence, we obtain explicit formulas for all the minors and for the inverse of totally nonnegative GCD matrices.