“It’s your New York soul coming out,” the mayor replied, in reference to Mr. Sanders’s Brooklyn roots, as the two climbed the stairs to the 34th Street platform. “Someone asked me about it the other day, and I said I missed the tokens.” (Mr. Sanders took heat in 2016 for suggesting tokens were still used on the city’s trains.)

After their ride, the pair arrived at a campaign-style event in the glittering new Fulton Center, a shopping center and subway hub near Wall Street, surrounded by supportive unions and Democratic politicians. Mr. de Blasio pushed once again for a tax on wealthy New Yorkers to support transit spending and provide discounted rides to the poor.

“You go outside, and walk a few blocks away, you will see the offices of the millionaires and billionaires who dominate this nation,” Mr. de Blasio said. “My friends, I know where the money is.”

Mr. Sanders, who was expected to hold an endorsement rally with Mr. de Blasio Monday night, said he supported the mayor’s plan. But he said he did not intend to pick sides in a dispute over transit funding between Mr. de Blasio and Gov. Andrew M. Cuomo, who has declared the mayor’s tax hike a non-starter in the Republican-dominated State Senate.

“I’m not taking sides, to be honest with you. I’ve got enough to keep me busy in Washington,” said Mr. Sanders, adding he just thought the mayor’s tax-the-rich plan was a good idea. “I think it’s the right thing to do.”