I discuss the interplay between non-Fermi liquid behavior and pairing near a quantum-critical point (QCP) in a metal. These tendencies are intertwined in the sense that both originate from the same interaction mediated by gapless fluctuations of a critical order parameter. The two tendencies compete because fermionic incoherence destroys the Cooper logarithm, while the pairing eliminates scattering at low energies and restores fermionic coherence. I discuss this physics for a class of models with an effective dynamical interaction V (W) ~1/|W|^g (the g-model). This model describes, in particular, the pairing at a 2D Ising-nematic critical point (g=1/3), a 2D antiferromagnetic critical point (g=1/2) and the pairing by an Einstein phonon with vanishing dressed Debye frequency (g=2). I argue the pairing wins, unless the pairing component of the interaction is artificially reduced, but because of fermionic incoherence in the normal state, the system develops pseudogap behavior in the temperature range between the onset of the pairing at Tp and the onset of phase coherence at the actual superconducting Tc. The ratio Tc/Tp decreases with g and vanishes atg =2. I present two complementary arguments of why this happens. One is the softening of longitudinal gap fluctuations, which become gapless at g =2. Another is the emergence of a 1D array of dynamical vortices, whose number diverges atg =2. I argue that a fundamentally novel superconducting ground state emerges atg >2.