Rep. Seth Moulton (Mass.), a Harvard-educated Marine veteran who struggled to gain traction in a crowded Democratic presidential field, announced Friday that he would close his campaign, making him the third candidate to depart the race in the past eight days.

“I am ending my campaign for president,” Moulton said in a Friday speech in San Francisco at the Democratic National Committee’s summer meeting. “Though this campaign is not ending the way we hoped, I am leaving this race knowing that we raised issues that are vitally important.”

Moulton argued that his veterans-focused campaign challenged President Trump “where he’s weakest, as commander in chief,” and worked to “take back patriotism from the Republican Party.”

The congressman attracted as much attention as he had since his April presidential debut on his concluding day, when Trump sought to blame him for a stock market slump that followed the president’s belligerent tweets about his handpicked Federal Reserve chief and his trade nemesis, China.

“The Dow is down 573 points perhaps on the news that Representative Seth Moulton, whoever that may be, has dropped out of the 2020 Presidential Race!” Trump tweeted.

Moulton follows Washington Gov. Jay Inslee and former Colorado governor John Hickenlooper, two Democrats who shuttered their bids for the White House in recent days as the nomination contest moves toward the fall — and as the DNC imposes stricter requirements for a spot at upcoming debates.

Inslee announced he would instead seek a third gubernatorial term next year, and Hickenlooper announced he would run against Sen. Cory Gardner (R-Colo.). Moulton said Friday that he would seek reelection to the House in Massachusetts’s 6th Congressional District near Boston.

“I can’t wait to get back at it,” Moulton said in his speech. Moulton’s exit from the 2020 race was first reported by the New York Times.

Moulton, 40, had been lingering near 1 percent or less in the polls and failed to qualify for the first two debates, in June and July. By early August, his campaign staff began to shrink following fundraising difficulties.

Despite the disappointment, Moulton told the DNC members that he walks away from the race proud of the way he shined a light on veterans’ issues and his own hardships. Moulton served as a Marine Corps captain during the Iraq War and was the recipient of a Bronze Star.

“For the first time in my life, I talked publicly about dealing with post-traumatic stress from my four combat tours in Iraq,” Moulton said. He called those discussions part of an effort to end “the stigma around mental health.”

Moulton’s low-key presence on the campaign trail, however, did little to win him notice.

“I’m not going around doing crazy things just looking for a viral moment,” Moulton said at a Washington Post Live event in June. “The case I’m making to the American people is that I’m not a crazy leader. I’m someone that you can trust, and you’re not going to agree with me on everything.”

In an interview with The Washington Post, Moulton said that “getting in late to the race was a handicap, much worse than expected. If I had gotten in even just a few weeks earlier, I probably would have made the first debate.”

But by waiting until April 22, Moulton joined a field that already had 18 candidates and was the most crowded primary in the party’s modern history. South Bend, Ind., Mayor Pete Buttigieg, 37, in particular, was surging at the time, and his presence made it harder for Moulton since they both were running on themes related to generational change and military experience.

Moulton said in The Post interview that he has had private conversations this month with former vice president Joe Biden, who leads the polls. Their latest exchange came Thursday, he said.

While Moulton is not ready to make an endorsement, he identifies with Biden’s pragmatic politics.

“I do think that Trump is going to be hard to beat,” Moulton said. “I think Vice President Biden would make a fantastic president. He’s a mentor and a friend, and I’ve been impressed by the campaign he has run so far.”

Moulton added, “It’s evident now that this is essentially a three-way race” among Biden, Sen. Elizabeth Warren (D-Mass.) and Sen. Bernie Sanders (I-Vt.).

Moulton said he worries that “veering too far left could lose us this election” and warned his party against embracing Medicare-for-all proposals on health care.

“I think we should strengthen Obamacare and have a robust public option that can compete against private plans,” Moulton said, echoing Biden’s approach. “I don’t think we should just take people off of that.”

Moulton is also known as a political rebel in the House, where he co-organized an effort to stop Rep. Nancy Pelosi (D-Calif.) from winning the speaker’s gavel.

He rejected the suggestion that his work against Pelosi’s speaker bid — he eventually supported her after weeks of talks — hurt his 2020 campaign.

“It’s basically Washington reporters who care about that,” Moulton said. “I’ve not met a single voter outside of Washington who says to me, ‘Seth, I wish you’d be a little more establishment and follow what your party leaders are telling you to do.’ It’s absurd.”

Moulton said he and Pelosi still have differences, including the party’s timeline for possibly impeaching Trump. Moulton wants the impeachment process to begin immediately and said Pelosi is making a “big mistake” by waiting to formally begin those proceedings.

Moulton plans to stay active in national politics in the coming months with events for veterans and for fellow Democrats through his Serve America PAC.

On Monday, Moulton will host a veterans’ town hall meeting in Fairfax, Va., with retired Army Gen. Stanley A. McChrystal, the former commander of U.S. forces in Afghanistan.

“I’m not going anywhere. I’m only 40 years old,” Moulton said in the interview with a chuckle.