CONCORD, N.H. — Michael F. Bennet, the senator from Colorado and former public school superintendent, is ending his campaign for the presidency, he said.

Bennet walked into his New Hampshire primary-night party shortly before 8:30, thanking the crowd and then key supporters like former senator and presidential candidate Gary Hart and James Carville, a Democratic consultant who endorsed Bennet.

“It’s fitting for us to end the campaign tonight,” Bennet said. “I love you, New Hampshire. Whether you knew it or not, we were having a great time together.”

Bennet did not announce support for any other candidate and hinted that the state would “see me again” in the future. But he reiterated that his party would be best served by a nominee with broad appeal and a popular agenda, focusing on expanding access to education and fighting climate change.

“I want you to be optimistic tonight,” Bennet said. “As James Baldwin wrote at the height of the civil rights movement: This is in our hands; we have no right to assume otherwise.”

Bennet had said Monday that he would need to finish in the top three or four in New Hampshire to continue.

His final push through the state included 50 town halls in the 10 weeks leading up to the primary, a tour in which he touted himself, a moderate Democrat, as someone who could defeat President Trump.

Bennet, 55, entered the race last May, a decision he made after successfully undergoing surgery for prostate cancer. First elected to the U.S. Senate in 2008, he touted his track record of working with Republicans and winning elections in Colorado, a “purple state.”

Unlike some of his more liberal opponents, Bennet opposed Medicare-for-all, instead supporting keeping private insurance while allowing people to buy into a public option. He called for doing away with the electoral college but did not support adding justices to the Supreme Court.

In a crowded primary field, Bennet found it difficult to break through, though he outlasted several other candidates. At one point, he tried to use his steadiness as an advantage, suggesting he would be boring compared with Trump — and that that was a good thing.

“If you elect me president, I promise you won’t have to think about me for 2 weeks at a time,” Bennet tweeted last August, a message he later converted into a campaign ad. “... So you can go raise your kids and live your lives.”

Toward the end of his campaign, Bennet focused most of his time and resources on New Hampshire while his opponents were crisscrossing Iowa. For much of January, however, Bennet found himself stuck in Washington for Senate impeachment proceedings, unable to travel to the Granite State to campaign.

He hung on through the Iowa caucuses, where he received zero percent of the state delegate equivalents and no national delegates.

Bennet was the second candidate to drop out Tuesday, after Andrew Yang earlier in the night announced the end of his presidential bid. Nine candidates remain in the hunt for the Democratic presidential nomination.

Wang reported from Washington.