Since then, the C.I.A. and its Saudi counterpart have maintained an unusual arrangement for the rebel-training mission, which the Americans have code-named Timber Sycamore. Under the deal, current and former administration officials said, the Saudis contribute both weapons and large sums of money, and the C.I.A takes the lead in training the rebels on AK-47 assault rifles and tank-destroying missiles.

The support for the Syrian rebels is only the latest chapter in the decades long relationship between the spy services of Saudi Arabia and the United States, an alliance that has endured through the Iran-contra scandal, support for the mujahedeen (islamists) against the Soviets in Afghanistan and proxy fights in Africa (Boko Haram). Sometimes, as in Syria, the two countries have worked in concert. In others, Saudi Arabia has simply written checks underwriting American covert activities.

The joint arming and training program, which other Middle East nations contribute money to, continues as America’s relations with Saudi Arabia — and the kingdom’s place in the region — are in flux. The old ties of cheap oil and geopolitics that have long bound the countries together have loosened as America’s dependence on foreign oil declines and the Obama administration tiptoes toward a diplomatic rapprochement with Iran.

And yet the alliance persists, kept afloat on a sea of Saudi money and a recognition of mutual self-interest. In addition to Saudi Arabia’s vast oil reserves and role as the spiritual anchor of the Sunni Muslim world, the long intelligence relationship helps explain why the United States has been reluctant to openly criticize Saudi Arabia for its human rights abuses, its treatment of women and its support for the extreme strain of Islam, Wahhabism, that has inspired many of the very terrorist groups the United States is fighting. The Obama administration did not publicly condemn Saudi Arabia’s beheading this month of a dissident Shiite cleric, Sheikh Nimr al-Nimr, who had challenged the royal family.(this also angered Iran)

Although the Saudis have been public about their help arming rebel groups in Syria, the extent of their partnership with the C.I.A.’s covert action campaign and their direct financial support had not yet been disclosed. Details were pieced together in interviews with a half-dozen current and former American officials and sources from several Persian Gulf countries. Most spoke on the condition of anonymity because they were not authorized to discuss the program.

From the moment the C.I.A. operation was started, Saudi money supported it.

“They understand that they have to have us, and we understand that we have to have them,” said Mike Rogers, the former Republican congressman from Michigan who was chairman of the House Intelligence Committee when the C.I.A. operation began. Mr. Rogers declined to discuss details of the classified program.

American officials have not disclosed the amount of the Saudi contribution, which is by far the largest from another nation to the program to arm the rebels against President Bashar al-Assad’s military. But estimates have put the total cost of the arming and training effort at several billion dollars.

The White House has embraced the covert financing from Saudi Arabia — and from Qatar, Jordan and Turkey — at a time when Mr. Obama has pushed gulf nations to take a greater security role in the region. Spokesmen for both the C.I.A. and the Saudi Embassy in Washington declined to comment.

When Mr. Obama signed off on arming the rebels in the spring of 2013, it was partly to try to gain control of the apparent free-for-all in the region. The Qataris and the Saudis had been funneling weapons into Syria for more than a year. The Qataris had even smuggled in shipments of Chinese-made FN-6 shoulder-fired missiles over the border from Turkey.

The Saudi efforts were led by the flamboyant Prince Bandar bin Sultan, at the time the intelligence chief, who directed Saudi spies to buy thousands of AK-47s and millions of rounds of ammunition in Eastern Europe for the Syrian rebels. The C.I.A. helped arrange some of the arms purchases for the Saudis, including a large deal in Croatia in 2012.

By the summer of 2012, a freewheeling feel had taken hold along Turkey’s border with Syria as the gulf nations funneled cash and weapons to rebel groups — even some that American officials were concerned had ties to radical groups like Al Qaeda.

The C.I.A. was mostly on the sidelines during this period, authorized by the White House under the Timber Sycamore training program to deliver nonlethal aid to the rebels but not weapons. In late 2012, according to two former senior American officials, David H. Petraeus, then the C.I.A. director, delivered a stern lecture to intelligence officials of several gulf nations at a meeting near the Dead Sea in Jordan. He chastised them for sending arms into Syria without coordinating with one another or with C.I.A. officers in Jordan and Turkey.

Months later, Mr. Obama gave his approval for the C.I.A. to begin directly arming and training the rebels from a base in Jordan, amending the Timber Sycamore program to allow lethal assistance. Under the new arrangement, the C.I.A. took the lead in training, while Saudi Arabia’s intelligence agency, the General Intelligence Directorate, provided money and weapons, including TOW anti-tank missiles.

The Qataris have also helped finance the training and allowed a Qatari base to be used as an additional training location. But American officials said Saudi Arabia was by far the largest contributor to the operation.

While the Obama administration saw this coalition as a selling point in Congress, some, including Senator Ron Wyden, an Oregon Democrat, raised questions about why the C.I.A. needed Saudi money for the operation, according to one former American official. Mr. Wyden declined to be interviewed, but his office released a statement calling for more transparency. “Senior officials have said publicly that the U.S. is trying to build up the battlefield capabilities of the anti-Assad opposition, but they haven’t provided the public with details about how this is being done, which U.S. agencies are involved, or which foreign partners those agencies are working with,” the statement said.

When relations among the countries involved in the training program are strained, it often falls to the United States to broker solutions. As the host, Jordan expects regular payments from the Saudis and the Americans. When the Saudis pay late, according to a former senior intelligence official, the Jordanians complain to C.I.A. officials.

While the Saudis have financed previous C.I.A. missions with no strings attached, the money for Syria comes with expectations, current and former officials said. “They want a seat at the table, and a say in what the agenda of the table is going to be,” said Bruce Riedel, a former C.I.A. analyst and now a senior fellow at the Brookings Institution.

The C.I.A. training program is separate from another program to arm Syrian rebels, one the Pentagon ran that has since ended. That program was purportedly to train rebels to combat Islamic State fighters in Syria, unlike the C.I.A.’s program, which has focused on rebel groups fighting the Syrian military.

While the intelligence alliance is central to the Syria fight, a constant irritant in American-Saudi relations is just how much the Saudis continue to support terrorist groups, analysts said.

“The more that the argument becomes, ‘We need them as a counterterrorism partner,’ the less persuasive it is,” said William McCants, a former State Department counterterrorism adviser and the author of a book on the Islamic State. “If this is purely a conversation about counterterrorism cooperation, and if the Saudis are a big part of the problem in creating terrorism in the first place, then how persuasive of an argument is it?”

In the near term, the alliance remains solid, strengthened by a bond between spy masters. Prince Mohammed bin Nayef, the Saudi interior minister who took over the effort to arm the Syrian rebels from Prince Bandar, has known the C.I.A. director, John O. Brennan, from the time Mr. Brennan was the agency’s Riyadh station chief in the 1990s. Former colleagues say the two men remain close, and Prince Mohammed has won friends in Washington with his aggressive moves to dismantle terrorist groups like Al Qaeda in the Arabian Peninsula.

The job Mr. Brennan once held in Riyadh is, more than the ambassador’s, the true locus of American power in the kingdom. Former diplomats recall that the most important discussions always flowed through the C.I.A. station chief.

The roots of the relationship run deep. In the late 1970s, the Saudis organized what was known as the “Safari Club” — a coalition of nations including Morocco, Egypt and France — that ran covert operations around Africa at a time when Congress had clipped the C.I.A.’s wings over years of abuses.

In the 1980s, the Saudis helped finance C.I.A. operations in Angola, where the United States backed rebels against the Soviet-allied government. While the Saudis were staunchly anticommunist, Riyadh’s primary incentive seemed to be to solidify its C.I.A. ties. “They were buying good will,” recalled one former senior intelligence officer who was involved in the operation.

In perhaps the most consequential episode, the Saudis helped arm the mujahedeen rebels to drive the Soviets out of Afghanistan. The United States committed hundreds of millions of dollars each year to the mission, and the Saudis matched it, dollar for dollar.

The money flowed through a C.I.A.-run Swiss bank account. In the book “Charlie Wilson’s War,” the journalist George Crile III describes how the C.I.A. arranged for the account to earn no interest, in keeping with the Islamic ban on usury.

In 1984, when the Reagan administration sought help with its secret plan to sell arms to Iran to finance the contra rebels in Nicaragua, Robert C. McFarlane, the national security adviser, met with Prince Bandar, who was the Saudi ambassador to Washington at the time. The White House made it clear that the Saudis would “gain a considerable amount of favor” by cooperating, Mr. McFarlane later recalled.

Prince Bandar pledged $1 million per month to help fund the contras, in recognition of the administration’s past support to the Saudis. The contributions continued after Congress cut off funding to the contras. By the end, the Saudis had contributed $32 million, paid through a Cayman Islands bank account.

When the Iran-contra scandal broke, and questions arose about the Saudi role, the kingdom kept its secrets. Prince Bandar refused to cooperate with the investigation led by Lawrence E. Walsh, the independent counsel.

In a letter, the prince declined to testify, explaining that his country’s “confidences and commitments, like our friendship, are given not just for the moment but the long run.”