The man was taken into custody outside a farm near the city of Nakano in Nagano region, with police confirming a fourth fatality overnight — an elderly woman who was found injured at the scene and later pronounced dead.
Another woman and two police officers were earlier confirmed dead in the attack.
Police told AFP that the 31-year-old suspect had been detained at about 4:30 am (1930 GMT Thursday), and later confirmed he had been formally arrested on suspicion of murder using a suspected hunting rifle.
The rampage in a rural area of the western region was a rare instance of violent crime in Japan, which has a low murder rate and some of the world’s toughest gun laws.
No motive has yet emerged in the killings, nor has the suspect been formally identified, though several local media reported he is the son of the speaker of Nakano’s city assembly.
“We pray for the souls of the deceased and express our heartfelt condolences to the bereaved families,” top government spokesman Hirokazu Matsuno told reporters.
“Police are investigating to uncover the whole picture of the incident, including how the crime developed and its background.”
‘Because I wanted to’
The attack started on Thursday afternoon, when a local man working on a farm saw a woman “running from the road saying, ‘help me’,” he told national broadcaster NHK.
“Behind her came a man wearing camouflage and carrying a large knife, who stabbed her in the back,” the 72-year-old witness said.
He said he called emergency services while neighbours tried to resuscitate the woman.
The attacker announced: “I killed her because I wanted to,” according to an eyewitness cited by Kyodo news.
Local media said he then fired what has been described as a hunting gun at police officers who arrived at the scene.
The officers were inside a patrol car and the attacker placed the weapon against a window of the vehicle and fired twice, NHK reported.
The slain officers were identified as Yoshiki Tamai, 46, and Takuo Ikeuchi, 61.
Local media said the man then barricaded himself inside his father’s home, where he remained most of the night, with occasional gunshots heard.
Two women, including the suspect’s mother, escaped the house, one at around 8:35 pm and the other soon after midnight.
The suspect was finally detained. A woman was found at the scene with injuries and later pronounced dead.
Japanwas left reeling in July last year when former prime minister Shinzo Abe was shot dead in broad daylight with an apparently homemade gun.
Abe’s accused assassin, Tetsuya Yamagami, reportedly targeted the politician over his links to the Unification Church.
And last month, a man was arrested for allegedly hurling a pipe bomb-like explosive towards Prime Minister Fumio Kishida as he campaigned in the western city of Wakayama.
Kishida was unharmed and a man arrested on the scene will undergo a three-month psychiatric examination, a regional court said this week.
The suspect has reportedly remained tight-lipped about his motive for that failed attack.