Mayor Pete Buttigieg took a dig at fellow 2020 candidate Sen. Bernie Sanders' supporters, drawing parallels between them and fans of President Trump during a campaign stop in New Hampshire.

"I think the sense of anger and disaffection that comes from seeing that the numbers are fine, like unemployment's low, like all that, like you said GDP is growing and yet a lot of neighborhoods and families are living like this recovery never even happened. They're stuck," Buttigieg told high school Democrats in Nashua, N.H., on Friday. "It just kind of turns you against the system in general and then you're more likely to want to vote to blow up the system, which could lead you to somebody like Bernie and it could lead you to somebody like Trump. That's how we got where we are."

Buttigieg, the 37-year-old mayor of South Bend, Ind., showered Sanders with praise in 2000 with a piece that won the then-18-year-old the John F. Kennedy Presidential Museum and Library's Profile in Courage Essay Contest award. But now he said it was "strange" to be contesting the Democratic Party's 2020 nomination against the Vermont senator, who is 77 years old.

"Part of running for president is you wind up competing with people that you like or appreciated or admired many years back," he said. "I don't have the same views on everything that he does."

Buttigieg has about 6% support compared to Sanders' 22.5%, according to RealClearPolitics' average of polls less than a year before the Iowa caucuses.

[Opinion: Conservatives should be extremely wary of Pete Buttigieg]