Treasury Secretary Nicholas F. Brady, unable to overcome the power of the agricultural lobby, apparently has lost his fight to impose new, far-reaching controls over stock index futures, which are part of the computerized trading that often rocks the financial markets.

Members of the Senate banking and agriculture committees, working around the clock to forge a consensus, yesterday scuttled the chief provision of an administration bill, which would have taken control of stock index futures away from the Commodity Futures Trading Commission and given it to the Securities and Exchange Commission. The senators' proposed compromise represents at this point the most the administration could hope for from Congress on the issue, according to Capitol Hill sources.

Brady, who lobbied hard for passage of his measure, faced the implacable opposition of the CFTC, the Chicago futures markets and members of Congress with close ties to the agricultural industry.

However, Brady may win on one key issue that could reduce the level of speculation present in the buying and selling of futures contracts on stock indexes in Chicago. This, in turn, could lessen the amount of program trading.

A futures contract on a stock index -- a selected group or "basket" of stocks -- allows traders to speculate on the future prices of those stocks. By trading in both markets, program traders can make large profits from small differences in prices of individual stocks in New York and stock index baskets in Chicago.

Brady, who headed an administration study of the 1987 market crash, claimed that stocks and stock indexes were part of one market and should have one regulator at the SEC, an idea vehemently rejected by the commodity markets' defenders on Capitol Hill.

In their compromise package, the senators agreed to:

Give the Federal Reserve authority over the margins, or good faith deposits, required to trade in the stock index pits in Chicago. The futures markets currently set their own margins and allow traders to control large amounts of stock for relatively small amounts of money.

Chicago's style of setting margins had drawn heavy fire from Brady and from SEC Chairman Richard C. Breeden, who charged that Chicago's practices encouraged speculation that, in turn, could lead to market crashes. The loss to the Fed of their power over stock index margins would be a major blow to the Chicago markets, which have prized that control.

Create new flexibility in the regulation and trading of hybrid products, which combine the features of stocks and futures. Arguments over where hybrid products should trade have led to disputes and legal battles between the CFTC and the SEC and have prevented some products from trading in this country.

The compromise effort, which kept Senate staffers working until 1:30 a.m. Friday morning, involved senators who serve on the Senate agriculture and banking committees.

They included Sen. Patrick J. Leahy (D-Vt.), chairman of Senate Agriculture, Sen. Richard G. Lugar (R-Ind.), Sen. Christopher J. Dodd (D-Conn.), Sen. John Heinz (R-Pa.), and Sen. Christopher S. Bond (R-Mo.).

The compromise, it was learned, will give the Fed authority to set margin rules for the stock-related products in Chicago. But it does not specifically tell the Fed how to do so.

Currently, the Fed sets the margin rules for stocks, requiring an investor to put up 50 percent of his purchase price. Fed Chairman Alan Greenspan has told Congress that the Fed did not want authority over futures margins and, indeed, would like the SEC to take over margin rules on stocks. Greenspan, however, did express concern over Chicago margin levels at the time of the mini-crash on Oct. 13, 1989.