The genome of hepatitis B virus (HBV) provides a striking example of gene overlapping. In particular, the surface protein gene S is overlapped completely by the polymerase gene P. Evolutionary constraints in overlapping genes have been demonstrated for many viruses, with one of the two overlapping genes being subjected to positive selection (adaptive evolution), while the other one is subjected to purifying selection. Yet, for HBV to persist successfully, adaptive evolution of both the P and S genes is essential. We propose that HBV employs a mechanism that allows the independent adaptive evolution of both genes. We hypothesize that (i) the adaptive evolution of P occurs via p1/s3 non-synonymous substitutions, which are synonymous in S, (ii) the adaptive evolution of S occurs via p3/s2 non-synonymous substitutions, which are synonymous in P, and (iii) p2/s1 substitutions are rare. Analysis of 450 HBV sequences demonstrated that this mechanism is operational in HBV evolution both within and among genotypes. Positions were identified in both genes where adaptive evolution is operational. Whilst significant parts of the P and S genes were subjected to positive selection, with the K(a)/K(s) ratio for either the P or the S gene being >1, there were only a few regions where the K(a)/K(s) ratios in both genes were >1. This mechanism of independent evolution of the overlapping regions could also apply to other viruses, taking into account the increased frequency of amino acids with a high level of degeneracy in the proteins encoded by overlapping genes of viruses.