A dark solitary wave, in one space dimension and time, is a wave that is bi-asymptotic to a periodic state, with a phase shift, and with localized modulation in between. The most well-known case of dark solitary waves is the exact solution of the defocusing nonlinear Schrödinger equation. In this paper, our interest is in developing a mechanism for the emergence of dark solitary waves in general, and not necessarily integrable, Hamiltonian PDEs. The focus is on the periodic state at infinity as the generator. It is shown that a natural mechanism for the emergence is a transition between one periodic state that is (spatially) elliptic and another one that is (spatially) hyperbolic. It is shown that the emergence is governed by a Korteweg-de Vries (KdV) equation for the perturbation wavenumber on a periodic background. A novelty in the result is that the three coefficients in the KdV equation are determined by the Krein signature of the elliptic periodic orbit, the curvature of the wave action flux and the slope of the wave action, with the last two evaluated at the critical periodic state.