Speaking to reporters later in the evening, Mr. Yang was asked if he would consider running for mayor of New York City. “I wouldn’t rule anything out,” he said.

Early in his campaign — sometimes in front of audiences of a few dozen people or less — Mr. Yang, the Schenectady, N.Y.-born former head of a test-prep company and a nonprofit organization, often sounded the alarm about what he called the “fourth industrial revolution.”

Automation, he warned, would bring mass unemployment, chaos and even violence if no remedy were pursued; free money combined with a more humane economic system, he argued, would buffer American society against its worst effects and help restore people’s dignity.

The candidate and a small campaign staff labored in relative obscurity for about a year until last February, when Mr. Yang went on a popular podcast and raised hundreds of thousands of dollars overnight. From there, he began a slow but steady rise, raising millions of dollars each quarter and moving from less than 1 percent in the polls to 4 and 5 percent early this year. His political operation grew and formalized.

Unlike several more experienced candidates, Mr. Yang qualified for all of the 2019 Democratic debates, and he appeared to grow more comfortable on the trail and the debate stages.

By the time the Iowa caucuses arrived, Mr. Yang was one of just 11 candidates in the Democratic field, which had at one point ballooned to two dozen.

But Mr. Yang’s modest rise also coincided with increased scrutiny of his policy proposals, his past treatment of employees and his handling of topics like race and gender. The news media began digging into the cost of his universal basic income proposal; he was criticized for saying at a debate, “I am Asian, so I know a lot of doctors”; and he faced claims of gender discrimination from campaign volunteers and past employees.