Legislation requested by President Barack Obama authorizing the military to arm and train moderate Syrian rebels fighting Islamic State militants in the Middle East is headed for his signature after a sweeping Senate vote.

The bipartisan 78-22 tally Thursday blended support from Obama's close Democratic allies and some of his fiercest Republican critics, including top Senate Republican Mitch McConnell of Kentucky. It put leading contenders for the 2016 Republican presidential nomination on opposite sides. Some of Obama's liberal allies defected.

The legislation also provides funding for the government after the end of the budget year on Sept. 30, eliminating any threat of a shutdown in the run-up to November elections that will seat a new House and decide control of the Senate. The House approved the bill on Wednesday.

Obama said the support from both Republicans and Democrats "shows the world that Americans are united" in combating the Islamic State group. He said the terrorists thought they could frighten or intimidate Americans, but the Senate vote had showed them they were wrong.

"As Americans, we do not give in to fear," Obama said. "We pull together. We stand together."

U.S. troops would train Syrian rebels at camps in Saudi Arabia, though the chairman of the Joint Chiefs of Staff, Gen. Martin Dempsey, said it could take a year before they would return to the battlefield in Syria. The arm-and-train authority only extends into December, and lawmakers are to revisit the issue in a postelection, lame-duck session.

Supporters of the proposal agreed that more has to be done to combat Islamic State extremists who have taken over large swaths of Iraq and Syria and shocked the world by beheading two American journalists and a British aid worker. The U.S. estimates the extremists can muster 20,000 to 31,500 fighters across Syria and Iraq, with two-thirds of them in Syria and the rest in Iraq. Terrorism experts say they are better organized and more dangerous than al-Qaida, which is lending urgency to the effort.

But opponents of Obama's strategy say it would hand weapons to shadowy groups that could prove untrustworthy and whose top priority is to topple Syrian President Bashar Assad.

"Intervention when both choices are bad is a mistake. Intervention when both sides are evil is a mistake. Intervention that destabilizes the Middle East is a mistake," said Sen. Rand Paul, R-Ky., who is considering a run for the White House in 2016. "And yet, here we are again, wading into a civil war."

Republican Sen. Ted Cruz, who's also weighing a presidential run, joined Paul in opposition, while Republican Sen. Marco Rubio, also a potential candidate, supported the president's request.

"We will confront ISIL one way or the other, and I believe the sooner the better," Rubio said, using an alternate acronym for the group. "What we are asked to do now is approve funding to arm moderate rebel elements in Syria. There is no guarantee of success. There is none. But there is a guarantee of failure if we do not even try."

Liberal opponents included rising Democratic star Sen. Elizabeth Warren of Massachusetts and Independent Sen. Bernie Sanders.

"Not only are countries in the region not stepping up in the fight ... but believe it or not several of these Gulf states are empowering" Islamic State forces as well as al-Qaida allied groups with financial contributions, Sanders said.

Some strong opponents of the war in Iraq swung behind the president, alarmed by the Islamic State threat.

"I am so cautious when it comes to voting to go to war," said Democratic Sen. Barbara Boxer. "In this case, if I were to sit back and say I'm too afraid, I'm too nervous, that is exactly the wrong signal to send."

More hawkish lawmakers said Obama's strategy won't be enough to blunt the advance of Islamic State forces. Obama has ordered U.S. airstrikes as well but is adamant that he won't send combat troops to battle the Islamic extremists.

Top administration officials again fanned out on Capitol Hill on Thursday to sell the president's strategy, with Secretary of State John Kerry pushing back on an argument by some in Congress that Syria's rebels lack moderates, or at least any with the capacity to make a difference in the war. He told the House Foreign Affairs Committee about several opposition groups, each comprising up to 4,000 fighters, which have battled Islamic State militants and other extremists over the past year.

Kerry said the coalition that will fight the Islamic State group counts 50 countries. He said countries in Europe, the Arab world and elsewhere had committed to taking part militarily, without specifying any by name.

Some senators opposed arming the Syrian rebels but voted for the measure anyway to avoid a government shutdown. Others, including Rubio, supported it despite opposing the underlying spending measure.