We present an implementation of smoothed particle hydrodynamics (SPH) in an adaptive particle-particle-particle-mesh (AP3M) algorithm. The code evolves a mixture of purely gravitational particles and gas particles. SPH gas forces are calculated in the standard way from near neighbors. Gravitational forces are calculated using the mesh refinement scheme described by Couchman (1991). The AP3M method used in the code gives rise to highly accurate forces. The maximum pairwise force error is set by an input parameter. For a maximum pairwise force error of 7.7%, the rms error in a distribution of particles is ≍0.3%. The refined-mesh approach significantly increases the efficiency with which the neighbor particles required for the SPH forces are located. The code, "Hydra," retains the principal desirable properties of previous P3M-SPH implementations; speed under light clustering, naturally periodic boundary conditions, and easy control of the accuracy of the pairwise interparticle forces. Under heavy clustering the cycle time of the new code is only 2-3 times slower than for a uniform particle distribution, overcoming the principle disadvantage of previous implementations a dramatic loss of efficiency as clustering develops. A 1000 step simulation with 65,536 particles (half dark, half gas) runs in one day on a Sun Sparc10 workstation.The choice of time integration scheme is investigated in detail. We find that a simple single-step predictor-corrector type integrator, which is equivalent to Leapfrog for velocity-independent forces, is the most efficient. A method for generating an initial distribution of particles by allowing a uniform temperature gas of SPH particles to relax within a periodic box is presented. The average SPH density that results varies by ≍ ±1.3%. This is the fluctuation amplitude on roughly the Nyquist frequency; for smaller wavenumbers the fluctuations have lower amplitudes. We present a modified form of the Layzer-Irvine equation which includes the thermal contribution of the gas together with radiative cooling. The SPH and time integration schemes were tested and compared by running a series of tests of sound waves and shocks. These tests were also used to derive time-step constraints sufficient to ensure both energy and entropy conservation. We have compared the results of simulations of spherical infall and collapse with varying numbers of particles. We show that many thousands of particles are necessary in a halo to correctly model the collapse. As a further test, the cluster simulation of Thomas & Couchman (1992) has been rerun with the new code, which includes a number of improvements in the SPH implementation. We find close agreement except in the core properties of the cluster which are strongly affected by entropy scatter in the older simulation. This demonstrates the crucial importance of conserving entropy in SPH simulations.