Infection with the hepatitis B virus can occur perinatally, parenterally, or sexually, and it can cause acute or chronic liver diseases. Phylogenetic analysis of the virus has led to its classification into eight genotypes (A-H), which show a characteristic worldwide distribution. The aim of this study was to reveal the HBV genotypes present in Hungary and to investigate a nosocomial and an intrafamilial outbreak. The collected samples were tested by nested PCR, and a 650-nucleotide-long segment of the preS1/preS2/S region was sequenced. As no previous genotype data were available from Hungary, sera of 24 HBsAg-positive patients were collected from different regions of the country. They also served as control samples for the molecular epidemiologic study. Nineteen of them carried genotype D of hepatitis B virus, and five of them carried genotype A. Twenty-nine patients from a haemato-oncology unit were affected in a nosocomial outbreak. The patients had haematological and/or oncological diseases, most of them were immunosuppressed. In twenty-eight cases, based on phylogenetic analysis of the viruses, there was presumably a common source of infection, and an epidemiological investigation showed that the infections seemed to be hospital-acquired. In the intrafamilial outbreak, two asymptomatic carrier children infected their foster mother. The three sequences were totally identical.