Although the 'trichotonomy problem' has been the subject of much debate, both a review of soft tissue anatomy (1) and recent genetic evidence (2,3) have shown that chimpanzees are almost certainly the closest relatives of humans. It is though that gorillas splt only a short time before the homo pan divergence which made the phylogeny difficult to resolve.
(1) Sally Gibbs, Mark Collard, and Bernard Wood. Soft-tissue characters in higher primate phylogenetics. 11130—11132 PNAS September 26, 2000 vol. 97 no. 20
(2) R. Wimmer, S. Kirsch, G. A. Rappold, and W. Schempp. Direct evidence for the Homo-Pan clade. Chromosome.Res. 10 (1):55-61, 2002.
(3) S. L. Page and M. Goodman. Catarrhine Phylogeny: Noncoding DNA Evidence for a Diphyletic Origin of the Mangabeys and for a Human—Chimpanzee Clade. Molecular Phylogenetics and Evolution Vol. 18, No. 1, January, pp. 14—25, 2001.