Police said they responded to a call at about 2:30 a.m. from an employee saying something horrible was happening at the facility in the city of Sagamihara, 50 kilometers (30 miles) west of Tokyo.
A man turned himself in at a police station about two hours later, police in Sagamihara said. He left the knife in his car when he entered the station. He has been arrested on suspicion of attempted murder and trespassing.
Officials in Kanagawa prefecture, which borders Tokyo, identified the suspect as Satoshi Uematsu, and said he had worked at the facility until February. Japanese media reports said he was 26 years old.
He entered the building about 2:10 a.m. by breaking a glass window on the first floor of a residential building at the facility, Shinya Sakuma, head of prefectural health and welfare division, said at a news conference.
Kanagawa Gov. Yuji Kuroiwa expressed his condolences to the victims.
The Sagamihara City fire department says that 19 people were confirmed dead in the attack. The fire department said doctors at the scene confirmed the deaths.
The death toll could make this the worst mass killing in Japan in the post-World War II era.
A woman who lives across from the facility told Japanese broadcaster NHK that she saw police cars enter the facility around 3:30 a.m.
“I was told by a policeman to stay inside my house, as it could be dangerous,” she said. “Then ambulances began arriving, and blood-covered people were taken away.”
Japanese broadcaster NTV reported that Uematsu was upset because he had been fired, but that could not be independently confirmed.
The facility, called the Tsukui Yamayuri-en, is home to about 150 adult residents who have mental disabilities, Japan’s Kyodo News service said.
Television footage showed a number of ambulances parked outside, with medical and other rescue workers running in and out.
Mass killings are relatively rare in Japan, which has extremely strict gun-control laws. In 2008, seven people were killed by a man who slammed a truck into a crowd of people in central Tokyo’s Akihabara electronics district and then stabbed passers-by.
Fourteen were injured in 2010 by an unemployed man who stabbed and beat up passengers on two public buses outside a Japanese train station in Ibaraki Prefecture, about 25 miles (40 kilometers) northeast of Tokyo.
A man who lives near the site of the latest attack said he was astonished such an attack happened in the quiet, semi-rural area near Mount Takao, a mountain popular with hikers.
“Serious crimes happen around the world,” said Chikara Inabayashi, who was tending his watermelon patch. “We have to lock up the house when we go out, even in the countryside.”