In a recent Brief Comment, the results of an experiment to measure the refraction of a particle beam were reported [P. Muggli et al., Nature 411, 43 (2001)]. The refraction takes place at a passive interface between a plasma and a gas. Here the full paper on which that Comment is based is presented. A theoretical model extends the results presented previously [T. Katsouleas et al., Nucl. Instrum. Methods Phys. Res., Sect. A 455, 161 (2000)]. The effective Snell's law is shown to be nonlinear, and the transients at the head of the beam are described. 3D particle-in-cell simulations are performed for parameters corresponding to the experiment. Additionally, the experiment to measure the refraction and internal reflection at the Stanford Linear Accelerator Center is described.