We study nonuniform sampling in shift-invariant spaces and the construction of Gabor frames with respect to the class of totally positive functions whose Fourier transform factors as hat{g}(xi )= prod _{j=1}^n (1+2pi idelta _jxi )^{-1} , e^{-c xi ^2} for delta _1,ldots ,delta _nin mathbb {R}, c >0 (in which case g is called totally positive of Gaussian type). In analogy to Beurling’s sampling theorem for the Paley–Wiener space of entire functions, we prove that every separated set with lower Beurling density >1 is a sampling set for the shift-invariant space generated by such a g. In view of the known necessary density conditions, this result is optimal and validates the heuristic reasonings in the engineering literature. Using a subtle connection between sampling in shift-invariant spaces and the theory of Gabor frames, we show that the set of phase-space shifts of g with respect to a rectangular lattice alpha mathbb {Z}times beta mathbb {Z} forms a frame, if and only if alpha beta <1. This solves an open problem going back to Daubechies in 1990 for the class of totally positive functions of Gaussian type. The proof strategy involves the connection between sampling in shift-invariant spaces and Gabor frames, a new characterization of sampling sets “without inequalities” in the style of Beurling, new properties of totally positive functions, and the interplay between zero sets of functions in a shift-invariant space and functions in the Bargmann–Fock space.