Cheng Chieh, a 21-year-old college student, was immediately arrested after the incident, the first fatal attack on the city's subway system since it began operations in 1996, police said.
The police, who had earlier put the number of injured at 25, said 22 travellers were wounded and hospitalised. Half of the wounded were in a serious condition, they said.
Three people were initially reported to have died in the attack and a fourth victim, a 62-year-old woman, died later in hospital. The other three victims were a woman and two men.
When the train pulled into the next station, Cheng fled and was chased by police before being kicked to the ground by a passenger and overwhelmed by security officials.
Also Read
Cheng spoke of his motives during police questioning.
"He told the police that he had wanted to do a 'big thing' such as this since his childhood," Chen Kuo-en, chief of the New Taipei City police bureau, told reporters.
The student bought two knives, including a 30-centimetre long knife and a smaller one at a supermarket in Taipei in preparation for the attack, Chen said.
Television images showed pools of blood in the train and passengers who survived the stabbings giving witness accounts.
"He started his attack from the last carriage of the train," a woman said as she gave her tearful account in an interview with the cable news network TVBS.
After being alerted to the attacks, authorities immediately reinforced police deployment on the busy subway system, which transports around 1.85 million visitors per day.