We study three-dimensional N = 2 supersymmetric gauge theories on Sigma(g) x S-1 with a topological twist along Sigma(g), a genus-g Riemann surface. The twisted supersymmetric index at genus g and the correlation functions of half-BPS loop operators on S-1 can be computed exactly by supersymmetric localization. For g = 1, this gives a simple UV computation of the 3d Witten index. Twisted indices provide us with a clean derivation of the quantum algebra of supersymmetric Wilson loops, for any Yang-Mills-Chern-Simonsmatter theory, in terms of the associated Bethe equations for the theory on R-2 x S-1. This also provides a powerful and simple tool to study 3d N = 2 Seiberg dualities. Finally, we study A-and B-twisted indices for N = 4 supersymmetric gauge theories, which turns out to be very useful for quantitative studies of three-dimensional mirror symmetry. We also briefly comment on a relation between the S-2 x S-1 twisted indices and the Hilbert series of N = 4 moduli spaces.