We have added a chemical filter to the ligand placement algorithm of the molecular docking program DOCK. DOCK places ligands in receptors using local shape features. Here we label these shape features by chemical type and insist on complementary matches. We find fewer physically unrealistic complexes without reducing the number of complexes resembling the known ligand-receptor configurations. Approximately 10-fold fewer complexes are calculated and the new algorithm is correspondingly 10-fold faster than the previous shape-only matching. We tested the new algorithm's ability to reproduce three known ligand-receptor complexes: methotrexate in dihydrofolate reductase, deoxyuridine monophosphate in thymidylate synthase and pancreatic trypsin inhibitor in trypsin. The program found configurations within 1 A of the crystallographic mode, with fewer non-native solutions compared with shape-only matching. We also tested the program's ability to retrieve known inhibitors of thymidylate synthase and dihydrofolate reductase by screening molecular databases against the enzyme structures. Both algorithms retrieved many known inhibitors preferentially to other compounds in the database. The chemical matching algorithm generally ranks known inhibitors better than does matching based on shape alone.