Libya is a failed state, according to the top U.S. general in Africa, who said that foreign fighters, weapons and illegal migrants are flowing through the oil-rich North African country, supplying the conflicts in Syria and Iraq with combatants and threatening U.S. allies.

In testimony Tuesday before the Senate Armed Services Committee, Army Gen. David Rodriguez said a recent agreement to form a government in Tripoli is an important step. Yet even with strong international support, the new unity government will struggle for the "foreseeable future" to establish its authority and secure Libya's people and borders, he said.

"The continued absence of central government control will continue to perpetuate violence, instability and allow the conditions for violent extremist organizations to flourish," Rodriguez told the committee.

Rodriguez's assessment comes nearly two weeks after Secretary of State John Kerry stopped short of declaring Libya as failed, citing the selection of a prime minister-designate to lead the new government.

"It's close," Kerry said last month during testimony before a Senate Appropriations subcommittee. "If they cannot get themselves together, yes, it will be a failed state."

Sen. Lindsey Graham, R-S.C., asked Rodriguez to quantify how much of Libya is under the control of extremist groups. Rodriguez replied that the Islamic State group controls the area in and around its stronghold city of Sirte.

The Islamic State has been recruiting militants from abroad into Libya in an effort to exploit years of chaos and expand its foothold there.

Sen. John McCain, R-Ariz., said the Islamic State now commands 5,000 fighters in Libya.