The House on Thursday rejected legislation from Rep. Matt Gaetz, R-Fla., that would require President Biden to remove most U.S. troops from Somalia, which opponents warned would hurt U.S. national security by making harder to fight al-Shabaab, a group the U.S. labeled a terrorist organization more than a decade ago.

House lawmakers rejected Gaetz’s resolution in a 102-321 vote, despite Gaetz’s argument that about 900 U.S. troops are in Somalia on a permanent, undefined mission that will never be enough to bring peace to that country.

During floor debate, Gaetz argued that to support Biden’s move last year to put troops back in Somalia, one would "have to believe that 900 U.S. troops is what is going to save a country of 17 million from a hardened group of 7,000," referring to al-Shabaab’s approximate strength.

"I think that strains not only logic but our understanding of the history of Somalia," Gaetz said.

GOP, DEMS TEAM UP TO KILL GAETZ RESOLUTION REMOVING US TROOPS FROM SYRIA

Matt Gaetz speaks with reporters

Rep. Matt Gaetz, R-Fla., pushed for a vote to remove U.S. troops from Somalia, but the House rejected the measure. (MANDEL NGAN/AFP via Getty Images)

"The future of Somalia must be determined by Somalia, and to the extent that foreign influences could be helpful, I would argue that the African Union is far better positioned to build a stronger sense of national identity and national unity among clans that have been warring in Somalia for generations than U.S. troops," he added.

Gaetz has also argued in recent weeks that the U.S. mission to train Somalis has resulted in some soldiers using that training to orchestrate coups throughout Africa. In March, Gaetz cited reports that say some U.S.-trained soldiers have led several coups and coup attempts, and asked U.S. Africa Command Gen. Michael Langley, USMC, why taxpayers should be funding this effort anymore.

"The American people have extremely low confidence in our military leaders and their ability to assess their own efficacy," Gaetz said in March when he introduced his resolution. "How do they expect Americans to believe their justification for occupying Somalia when they can’t even determine who in their own training programs will lead a violent coup afterwards?"

MATT GAETZ WANTS ALL US TROOPS PULLED FROM SYRIA, CLAIMS BIDEN LIED ABOUT MILITARY PRESENCE

Rep. John James

Rep. John James, R-Mich., seen here as a candidate in 2018, argued against Gaetz's resolution to remove troops from Somalia. (Photo by Bill Pugliano/Getty Images) (Bill Pugliano/Getty Images)

But most Republicans and Democrats disagreed with him.

Rep. John James, R-Mich., a West Point graduate who served in Iraq, warned that abandoning Somalia "will not work," and said Gaetz’s plan too closely mirrored President Biden’s chaotic and deadly withdrawal from Afghanistan.

"Joe Biden’s botched Afghanistan withdrawal forced our troops to abandon billions of dollars in taxpayer-funded military equipment, it resulted in 13 young American service members dead, it left hundreds of thousands of American veterans who served in Afghanistan wondering if their efforts were in vain, it embarrassed America on the world stage and left a gaping hole that China and the Taliban rushed to fill in," he said. "What have we learned?"

Democrats also backed Biden’s move to send troops back to Somalia last year by saying a U.S. presence there is needed.

GAETZ INTRODUCES RESOLUTION TO END MILITARY AND FINANCIAL AID TO UKRAINE, URGE PEACE DEAL

Rep. Meeks

Rep. Gregory Meeks, D-N.Y., said leaving Somalia would make it harder to work with U.S. partners in the region. (Tom Williams/CQ-Roll Call, Inc via Getty Images) (Tom Williams/CQ-Roll Call, Inc via Getty Images)

"The resolution fails to end our involvement in hostilities in the region while preventing crucial security cooperation with local partners in Somalia," said Rep. Gregory Meeks, D-N.Y., during floor debate.

The vote is the second attempt by Gaetz to bring U.S. troops home in the new Congress. In early March, Gaetz called up a resolution to remove about 900 U.S. troops in Syria, which he warned could only become mired in that country’s civil war.

CLICK HERE TO GET THE FOX NEWS APP

That resolution failed in a 103-321 vote that again saw majorities in both parties reject it.