President Obama has won preliminary congressional support for his plan to go on the offensive against the Islamic State in Iraq and Syria.

On a vote of 78-22, the Senate passed legislation on Thursday that included authorization that Obama requested to arm and train moderate Syrian rebels fighting ISIS on the ground. The language was included in a broader spending bill that prevents a government shutdown at the end of September.

The action comes a day after the House added the Syria language to the spending bill. But unlike the House, and to the dismay of several Democrats and Republicans, the Senate did not hold a separate vote on the war provision, merely tucking it into the larger bill and sending it to Obama as a package.

Debate over the measure is pitting potential Republican presidential contenders against one another.

Sen. Rand Paul/AP

Sen. Rand Paul (R-Ky.), an all-but-declared candidate in 2016, railed against Obama's proposal in an afternoon speech, decrying the president "and his Republican allies" who have clamored for intervention in Syria.

Paul argued that by intervening into "chaos," Obama was repeating the mistakes of the past.

"Will we ever learn?" he asked.

President Obama now wishes to bomb ISIS and arm their Islamic allies in Syria. The emperor has no clothes. Admit it. The truth is sometimes painful. We must protect ourselves from radical Islam, but we should never, ever have armed radical Islam, and we could make it worse by arming it more today. We have enabled the enemy we must now confront."

Without naming him, Paul seemed also to aim his fury at his hawkish nemesis, Sen. John McCain (R-Ariz.), referring at one point to the "barnacled enablers" and at another to "the barnacled purveyors of war."

McCain has criticized Obama for not doing enough to combat ISIS, and he lit into the president over a report that he intended to personally oversee the military's airstrikes in Syria.

The former prisoner of war said he had seen that movie before. "It was called Vietnam."

Now we have a president of the United States who is selecting targets of which he has no fundamental knowledge whatsoever."

Sen. John McCain/AP

Still, McCain said he would vote for the measure because, he argued, "to do nothing obviously would be a serious mistake."

McCain's fellow GOP hawk, Sen. Lindsey Graham (R-S.C.), also voted yes while arguing that Obama's insistence that he would never deploy ground troops to the region was "the Achilles heel" of his strategy.

He called the plan to arm Syrian rebels "a first step in the right direction."

"When the president does the right thing," Graham said, "I want to support him."

Another Republican presidential hopeful, Sen. Marco Rubio (R-Fla), also voted against Paul and with Obama. But he, too, did so grudgingly, having criticized the president for not acting more decisively against ISIS sooner.

"I suppose that like most things, better late than never," Rubio said.

Another Republican who may run for the White House, Sen. Ted  Cruz (Tex.), voted against the bill.

As in the House, the Senate vote did not fall strictly along party lines.

Sen. Mark Begich (D-Ala.), one of the most vulnerable Democratic senators, took to the floor to voice his disagreement with Obama and to complain that the Senate was lumping the war language into a spending bill and not voting on it separately.

A number of senators called for a longer debate over a formal authorization of military force, and Sen. Dick Durbin (D-Ill.), the second-ranking Democrat, said that was likely to come after the election.

UPDATE: President Obama delivered a statement from the White House on Thursday evening thanking Congress for its support of his mission.

I’m pleased that Congress – a majority of Democrats and a majority of Republicans, in both the House and the Senate – have now voted to support a key element of our strategy: our plan to train and equip the opposition in Syria so they can help push back these terrorists. As I said last week, I believe that we’re strongest as a nation when the president and Congress work together.  And I want to thank leaders in Congress for the speed and seriousness with which they approached this urgent issue -- in keeping with the bipartisanship that is the hallmark of American foreign policy at its best."