At least one person was stabbed by the knife-wielding man, who then set a fire aboard the train.
Witnesses described seeing people escaping through the train's windows in panic.
Of the 17 injured parties, three are said to have suffered serious wounds.
Police have named the attacker as 24-year-old Kyota Hattori. He was arrested on the spot and will now face charges of attempted murder.
The rampage began when Hattori produced a knife and stabbed a man in his 70s who was seated on the train. No details of how the 16 other victims received their injuries have been released.
Hattori told authorities that he was inspired by a previous train attack and that he wanted to get the death penalty.
A video released on social media shows Hattori calmly smoking while seated on the train in the aftermath of the attack. He appears to be dressed as comic book villain the Joker.
こやつが
京王線の犯人です右手にナイフ
左手にタバコめちゃくちゃ手は震えてたとにかくこいつにむかつきました
すごくみんな必死に逃げて
僕がみんなに窓から出ろ言い死にものぐるいでみんなででてたこいつの前まで来ました本当に許せなかった
殴りたかったです
#京王線#京王線刃物#犯人 pic.twitter.com/fdlLN9nj1Z— 生形たけし (@takahashi9811) October 31, 2021
Japanese media reported Hattori pouring a flammable liquid on the train before starting a fire in the carriage. There are unconfirmed reports that he sprayed acid on passengers.
It's the second major train attack in Tokyo in recent months. In August 10 commuters were stabbed by a man who later said he wanted to attack women who looked happy.