NASHUA, N.H.—Even as Pete Buttigieg savors a second-place finish just shy of a win in New Hampshire’s presidential primary, the road ahead looks much more challenging.

His struggle so far to draw any significant support from nonwhite voters is now an urgent hurdle as the Democratic contest moves to the more racially and ethnically diverse states of Nevada and South Carolina later this month.

By finishing in the top two in both Iowa and New Hampshire along with Sen. Bernie Sanders of Vermont, Mr. Buttigieg has established himself as a serious candidate. But the 38-year-old former mayor of South Bend, Ind., must now prove he can assemble a diverse coalition of voters beyond the white, well-educated ones who have been most drawn to him.

Iowa and New Hampshire both have populations that are more than 90% non-Hispanic white. That compares with 61.5% for the U.S. as a whole, and Mr. Buttigieg has never polled nationally as high as he did in those two early states.

New threats may also be emerging. Sen. Amy Klobuchar, who is also competing for the votes of moderate Democrats, surged to third place in New Hampshire from fifth in Iowa’s Feb. 3 caucuses. Former Vice President Joe Biden, who occupies the same lane and finished fifth on Tuesday, has promised a resurgence as more diverse states begin voting.