James was taken into custody in Manhattan’s East Village neighbourhood, after a 30-hour expansive search.
"My fellow New Yorkers: we got him," New York City Mayor Eric Adams said in a press briefing, adding that James had been apprehended without incident.
"There was nowhere for him to run," New York's Police Commissioner Keechant Sewell said at the briefing.
The police reportedly captured James after receiving a tip from the public. Sewell said James was taken into custody without incident and will be charged over Tuesday's attack. Video footage showed a man resembling James being handcuffed and being taken into a police car.
The New York Police Department had earlier asked the public to come forward if they possessed any information on his whereabouts. They had also offered a $50,000 reward for information that leads to the arrest of the culprit.
James, who has nine prior arrests in New York City and three arrests in New Jersey, faces a federal charge of carrying out a terrorist attack on mass transportation, officials said.
Earlier on Wednesday, Adams had said that James, who had originally been named a "person of interest" in the shooting in the city on Tuesday, was being considered a suspect.
Adams told Bloomberg that this development was based on a briefing from law enforcement officials and the evidence that has been collected so far.
What Had Happened?
Twenty-three people were injured on Tuesday after James opened two canisters of smoke and opened fire on the platform of a Brooklyn subway station in New York City.
Of the 23 people wounded, 10 were injured by the gunfire and an additional 13 were either injured as they rushed to get out of the train station or suffered smoke inhalation, said Sewell.
Verified videos viral on social media showed a train pulling into the station on Tuesday, as passengers rushed out. Smoke was seen coming out from the train station.
What Clues Did the Police Find?
Police officers had found a collection of belongings that were left on the train in which the attack took place, like a Glock 9-millimeter handgun and the key to a van that was later found a few blocks away. A credit card, which had James' name, had also been found at the shooting site.
According to officials, the van was rented by James, that too in Philadelphia sometime over the last few days.
The police also say that James drove the van to an area of Brooklyn near the subway line where the shooting happened.
James had posted several videos on YouTube, where he delivered "long and sometimes aggressive political tirades." The videos were later taken down as they violated YouTube's Community Guidelines. In one of the videos, he also criticised New York's mayor.
His sister, Catherine James Robinson, told The New York Times that she was surprised when he was named as a suspect. "I don't think he would do anything like that," she said.
(With inputs from Bloomberg and AFP.)