By Joseph Ax and Doina Chiacu

(Reuters) - Andrew Yang, an entrepreneur whose unlikely White House bid evolved into a serious campaign thanks to grassroots enthusiasm, pulled out of the Democratic presidential race on Tuesday after New Hampshire delivered him a second straight poor showing.

Yang, 45, who ran for president despite having no political background, surprised many observers by qualifying for debates and remaining in the contest longer than some veteran politicians.

The Ivy League-educated son of Taiwanese immigrants, who was bidding to be the country's first Asian-American president, launched his long-shot candidacy in 2017 as a virtual unknown.

Yang's signature proposal, a universal basic income that would pay every American $1,000 a month, was his answer to the "fourth industrial revolution," the rise of automation that he said destroyed millions of manufacturing jobs and, as a consequence, paved the way for Donald Trump's 2016 election.

Yang told supporters in New Hampshire on Tuesday night he would support whoever wins the Democratic nomination to take on Trump in November, while continuing to push his own message.

"This is just the starting line. This campaign has awakened something fundamental in this country and ourselves," he said.

On the trail, Yang warned that automation would hit major industries like retail, customer service and trucking. He noted that technology companies were paying almost no taxes despite profiting from people's personal data, and vowed to impose new taxes on tech giants to finance his "Freedom Dividend."

Supporters said they were drawn to Yang's diagnosis of the country's problems, saying it resonated much more than a typical politician's speech. His devoted followers, fueled in part by his campaign's savvy use of social media, called themselves the "Yang Gang."

He had long pointed to New Hampshire as a natural place for him to succeed given its large proportion of independent voters. But the results on Tuesday - and last week in Iowa - made it unlikely he could raise enough money to continue campaigning.

As senators and governors saw their campaigns fizzle in what was the largest field of presidential candidates in U.S. history, Yang qualified for almost every debate thanks to a broad donor base and solid polling figures.

He was fond of noting he was the "opposite" of Donald Trump: "An Asian guy who likes math."

He often sported a MATH hat, which also stood for "Make America Think Harder."

He was a funny and amiable presence on the campaign trail, cracking jokes and occasionally breaking into dance.

At a CNN town hall in New Hampshire last week, Yang got several questions from undecided voters until he finally smiled and said, "One of you should just pretend to be for me," drawing laughs from the crowd.

(Reporting by Doina Chiacu and Joseph Ax; Editing by Colleen Jenkins and Sonya Hepinstall)