Police said the perpetrator, believed to have acted alone, fled the scene.
The attack unfolded as a Manhattan-bound subway train on the N line was pulling into a station in Brooklyn's Sunset Park neighbourhood, setting off an intense manhunt.
Ten people were hit directly by gunfire, including five hospitalised in a critical but stable condition.
Authorities said seven others were injured by shrapnel or otherwise hurt in the chaos as panicked riders fled the smoke-filled subway car and poured onto the platform of the 36th Street station.
The suspect was described by police as a man of heavy build, wearing a green construction-type vest and a hooded sweatshirt.
Fox News and local TV station WNBC reported the New York City Police Department later located a van with Arizona license plates that authorities had been looking for in connection with the shooting. The suspect remained at large.
NYPD Commissioner Keechant Sewell said the shooting was not being investigated as an act of terrorism, although authorities would not rule anything out as a motive.
Sewell said the suspect was seen donning a gas mask in the train car as it was about to enter the station, then removed a canister from his bag and opened it.
"The train at that time began to fill with smoke. He then opened fire, striking multiple people on the subway and in the platform," she said.
Outside the station, in an area known for its thriving Chinatown and views of the Statue of Liberty, authorities shut down a dozen or so blocks and cordoned off the immediate vicinity.
John Butsikares, a 15-year-old who passed through the 36th Street station soon after the incident, said the train's conductor ordered everyone on the station platform to get on board.
"I didn't know what happened. It was a scary moment. And then at 25th Street (the next station) we were all told to get off," he said.
"There were people screaming for medical assistance."
New York, the nation's most populous city, has seen a sharp rise in violent crime during the COVID-19 pandemic, including a string of seemingly random attacks on its subways.
The subway violence has included a number of attacks in which passengers have been pushed onto the tracks from platforms, including a Manhattan woman whose murder was seen as part of a surge in hate-driven attacks against Asian Americans.
Mayor Eric Adams, a former NYPD captain who took office in January, has vowed to improve subway safety by increasing police patrols and expanding outreach to the mentally ill.
Speaking to CNN, Adams said Tuesday's incident "was a senseless act of violence" and pledged to double the number of officers on subway patrol.
New York Governor Kathy Hochul pledged "the full resources of our state to fight this surge of crime, this insanity that is feeding our city."
Transit investigators found containers with gasoline and additional, unused smoke canisters on the train carriage, television station WNBC reported, citing city transit sources.
CNN, citing law enforcement sources, said multiple high-capacity ammunition magazines and fireworks were found in the subway station with the gun, which apparently jammed.
Speaking on a radio interview, Adams confirmed media reports of "some form of malfunction" in the station's security camera system, which could hamper the investigation.
How many cameras were affected was not immediately clear, he said.
However, investigators obtained cell phone video from an eyewitness that shows the suspect, a law enforcement source told CNN.