District of Columbia voters yesterday overwhelmingly defeated a referendum that would have legalized betting on jai alai, dog racing and a daily numbers game in the nation's capital.

The controversial gambling initiative was rejected by a 3-to-2 margin, with the strongest opposition in Ward 3, the affluent, predominantly white area west of Rock Creek Park, where voters defeated the measure by a margin of more than 4 to 1.

Sen. Edward M. Kennedy of Massachusetts, winning all eight of the city's wards, defeated President Carter by a 3-to-2 margin in the District's Democratic presidential primay.

Thirteen delegates to the Democratic National Convention were at stake in yesterday's primary. They will be apportioned according to Carter's and Kennedy's vote percentages. As a result, Kennedy is likely to get eight of the 13. Another six delegates will be chosen later, bringing the city's total delegation to 19.

George Bush won the city's Republican presidential primary and all 14 delegates to the Republican National Convention that were at stake. Bush ran strongly throughout the District and captured two out of every three votes.

Rep. John B. Anderson of Illinois, whose name was on the ballot even though he has withdrawn from the GOP presidential race and is now an independent, ran a distant second behind Bush. Ronald Reagan, the national front-runner for the Repbulican presidential nomination, did not enter the D.C. primary.

Here are the final, unoffical returns in the District of Columbia presidential primaries and on the gambling referendum: Republican Presidential Primary (TABLE) 02,20,07 George Bush(COLUMN)4,849 John B. Anderson(COLUMN)1,952 Philip M. Crane(COLUMN)267 Harold Stassen(COLUMN)192 Benjamin Fernandez(COLUMN)59(END TABLE) Democratic Presidential Primary (TABLE) Edward M. Kennedy(COLUMN)38,688 Jimmy Carter(COLUMN)23,095 Lyndon H. LaRouche Jr.(COLUMN)868 (END TABLE) Gambling Referendum (TABLE) No(COLUMN)50,260 Yes(COLUMN)33,607 (END TABLE)

The gambling proposal, drafted by proponents of legalized wagering, was soundly defeated throughout the city, winning only in Ward 8 in Far Southeast Washington near the Prince George's County line.

Around 100 cheering opponents of the gambling initiative gathered at Bethesda Baptist Church in Northeast Washington last night to watch the returns on television and savor the victory. At times, the gathering resembled a religious revival meeting, with ward captains of the antigambling effort standing one by one to recount their successes in getting out the vote.

"I say praise the Lord," said the Rev. John D. Bussey, pastor of Bethesda Baptist Church and leader of the poorly financed group of black Baptist ministers that spearheaded the fight against the gambling proposal. "It's the answer to prayer. We had no resources, we had no skill in manipulation of public opinion. We prayed."

Bussey, himself a reformed gambler, said the victory showed that "we have more people in the District of Columbia who were concerned about the moral and religious aspects of gambling than people think."

Brant Coopersmith, chairman of the umbrella group that was promoting the gambling measure, said late last night, "It looks pretty bad. I don't know if there's any magic about conceding, but we're assuming that we've lost." k

Later, he did concede and said that the progambling group would now try to get the City Council to pass a measure allowing only daily numbers and lottery games. These games would have been the biggest fund-raisers of all the components of the gambling measure defeated yesterday, and they also were the least controversial.

With interest running relatively high in the election because of the gambling initative, yesterday's unexpectedly high turnout exceeded the 33,000 total 1976 presidential primary turnout by early afternoon. Interest had peaked in the last few days as numberous people raised doubts about the gambling proposal, including U.S. Attorney Charles F. C. Ruff, who delivered a highly unusual stinging attack on the provisions for jai alai and dog racing.

However, Ruff last night took no credit for the measure's defeat and said he was somewhat surprised by the outcome since gambling proponents had consistently "thought they had it wrapped up. It's marvelous the people have a way to speak."

Attracted by warm temperatures and mostly sunny skies, many voters went to the polls early. But when they got there, they were faced with some balky voting machines and lengthy, complicated ballots.

In some polling places, voters remained in line for more than an hour after the polls had closed to cast their ballots.

Carter's defeat was a somewhat of a blow to D.C. Mayor Marion Barry, who was the president's chief -- though often reluctant -- surrogate campaigner.

"I knew all along that Kennedy would win," said Barry, reached last night at Carter campaign headquarters. "This is Kennedy country. Bobby won here in '68 and a lot of supporters of mine and friends supported Kennedy. This vote doesn't surprise me, but you don't say that during a campaign."

Barry was criticized by some other members of the Carter camp for doing virtually no campaigning until last week.

"I never put my political reputation on the line," Barry said. "I said early on that I would just do all that I could, that I would support the president. I'm not depressed or anything."

Barry, who supported legalized gambling as a member of the City Council, said he believed many voters who rejected the proposal yesterday would support a measure that legalized only a numbers game.

About 250 jubilant Kennedy supporters gathered at his D.C. headquarters last night to drink beer, sip California Rhine wine and cheer their favorite candidate's victory.

Del. Walter E. Fauntroy, who campaigned hard for Kennedy and against the gambling initiative, said, "I'm just very pleased that the issues I have supported have been supported by the people of this city." Fauntroy, was unopposed for nomination to a sixth term yesterday.

He said he believed Kennedy's support among black voters was "certainly affirmed" by yesterday's vote, and predicted that future primary contests would see a "substantial switch to Kennedy" in the nation's urban centers.

City Council Chairman Arrington Dixon, a twin loser yesterday in that he supported Carter and the gambling proposal, played down the defeats. He pointed to Carter's victories in yesterday's other primaries, and said his support of the gambling measure was primarily for the city-run lottery, which he said he believes voters support.

Many voters interviewed at polls throughout the city yesterday said they were not opposed to gambling per se, and were not adverse to the creation of a city-run lottery.

But yesterday's proposal was an all-or-nothing plan that would have legalized dog racing and jai alai, a fast-tempo Spanish indoor court game, as well. And many voters said they were flatly opposed to that.

"I'd like to see it come up again without the dogs," said Ralph Raymond, a D.C. parole officer, as he left Precinct 64 at Rabaut Junior High School in Northwest Washington.

Other voters said they feared that most of the wagering would be done by low-income blacks who could least afford it. Several said they resented the alleged effort of gambling proponents to hide the more controversial jai alai and dog-racing provisions and make it seem that the measure would only create lotteries.

Others said they were displeased that gambling profits would pass through a gaming control board before being allotted to city departments, special education programs and nonprofit agencies serving city residents.

"I didn't like the idea of the [estimated $35 million in annual gambling revenue] not going [directly] to the D.C. treasury," said Burllock Wells, who voted against the proposal. "It seemed to me that blacks just wouldn't be the beneficiaries of this."

Despite its status as the center stage of national politics, the city's Democratic presidential primary was in many ways a forgotten one.

And characteristically, neither Kennedy, who was campaigning in Baltimore, nor White House press secretary Jody Powell mentioned the District primary results last night.

The D.C. primary occurs late in the campaign season and involves only 19 of the 3,331 delegates sent to the Democratic National Convention. Rarely did the candidates make personal appearances here and political organizations were plagued with little money, scarce supplies and occasional infighting.

Most of the major politicians in the city, including Mayor Marion Barry, sided with Carter. Others, including Del. Walter Fauntroy, chose Kennedy. Conventional political wisdom in the city made Kennedy the favorite, because of the long-standing affection that many of the city's black voters were felt to have for the kennedy family.

Only in the final days did active campaigning for the presidential contest pick up. And still, the presidential primary was overshadowed by the showdown over legalized gambling.

The gambling campaign developed into a lively free-for-all in the last two weeks involving a variety of people, in addition to the ministers who always opposed gambling.

The two major points of opposition were the controversy surrounding jai alai and dog racing, and the powers of a five-member Gaming Control Board that would regulate betting if the referendum was approved.

Several City Council members attacked a provision in the bill that would allow the board to direct, with the approval of the mayor and the council, how gambling revenue should be spent. These critics said that the money should be sent directly to the treasury of the cash-strapped city government. Eight of the council's 13 members said they opposed passage of the referendum.

The gambling foes also noted that there are current criminal investigations of jai alai game-fixing in Connecticut and Florida. Animal welfare advocates joined the fray with an attack on dog racing, saying that trainers in the sport often use live lures -- rabbits, kittens and piglets -- to entice the greyhound dogs into becoming speedy racers.

On the last days of the campaign, WJLA-TV (7) and WDVM-TV (9) editorialized against passage of the referendum, as did The Washington Post, The Washington Star and The Washington Afro-American.

As a result, gambling proponents were often forced to take a defensive posture, observing with increasing frequency in recent days that any provision in the measure that people didn't like could be amended by the City Council.

At the same time, gambling supporters squarely laid their chances for winning passage of the initiative on D.C. residents' obvious pleasure in playing both the illegal numbers game in the city and the legal game run by the state of Maryland.

The gambling supporters repeatedly told voters that the only way to stop Maryland from collecting millions of dollars from D.C. residents who bet in that state's lottery was to start one in Washington.

Gambling proponents easily outspent the ministers' group by collecting large donations from Washington Jai Alai Corp., which sought to open an arena here; manufacturers of lottery computers and tickets; D.C. liquor dealers who wanted to be able to sell lottery tickets like their Maryland competitors to reap the sometimes lucrative ticket sales commissions, and the Columbia Kennel Club, here.

D.C. residents also voted yesterday for members of the Democratic and Republican state committees, the policy-making local party organizations, and for the positions of Democratic and Republican national committeeman and committeewoman. Results of those races were not immediately available last night.