In this article, we present a new technique for the rapid and precise docking of peptides to MHC class I and class II receptors. Our docking procedure consists of three steps: (1) peptide residues near the ends of the binding groove are docked by using an efficient pseudo-Brownian rigid body docking procedure followed by (2) loop closure of the intervening backbone structure by satisfaction of spatial constraints, and subsequently, (3) the refinement of the entire backbone and ligand interacting side chains and receptor side chains experiencing atomic clash at the MHC receptor-peptide interface. The method was tested by remodeling of 40 nonredundant complexes of at least 3.00 A resolution for which three-dimensional structural information is available and independently for docking peptides derived from 15 nonredundant complexes into a single template structure. In the first test, 33 out of 40 MHC class I and class II peptides and in the second test, 11 out of 15 MHC-peptide complexes were modeled with a Calpha RMSD < 1.00 A.