There are three primary laws that define the age of consent: the Penal Code of Japan, the Juvenile Obscene Acts and the Civil Codes. Each of these set out different definitions of when sexual activity is acceptable, with some applying to the whole of Japan and others to specific prefectures (Japan is divided into 47 administrative jurisdictions).
The Penal Code of Japan was established in 1907 and sets the age of consent at 13. Any sexual activity with a person under this age is always considered to be statutory rape and can result in a prison sentence of up to 20 years. However, chapter 34 of the Children Welfare Act also forbids any act of 'fornication' with children (defined as anyone under 18 years of age).
The Juvenile Obscene Acts, which take precedence over the Penal Code, set out laws relating to the age of consent for specific prefectures. In some, sexual activity with anyone below the age of 15 is illegal, but in others the age of consent is as high as 18. In these prefectures, engaging in sexual activity with a person under the age of consent can lead to a prison sentence of up to five years, depending on the prefecture. Although rare, in some prefectures, even hugging or holding hands with someone underage can be illegal.
The Civil Codes again approach the age of consent at the prefecture level (and sometimes municipalities within a prefecture). In Japan, anyone under the age of 20 is not considered to be an adult, so parental consent plays a significant role in legal issues affecting young people under this age (for example, no one under 20 can sign a legal contract without parental consent). In relation to the age of consent, this means that, in some prefectures, it is illegal to date a person under the age of 20 without written consent from their parents. This applies regardless of the age of the partner as Japan does not have a 'close-in-age exemption' in relation to the age of consent (i.e. even if one person is 20 and the other is 19).