District of Columbia City Councilman Marion Barry took a surprising, but narrow, lead in early returns last night in an extraordinarily close race with his two rivals for the Democratic mayoral nomination, Mayor Walter E. Washington and City Council Chairman Sterling Tucker.

With about one-third of the vote counted, Barry was leading both Washington and Tucker by fewer than 750 votes. The early returns included ballots cast in seven of the city's eight wards before 12:30 yesterday afternoon, but did not include votes from the diverse Ward 1, which includes fashionable Kalorama neighborhood, the Adams-Morgan community, the Cardozo area and neighborhoods around Howard University.

Most polls taken during the highly intense, eight-month campaign for the Democratic mayoral nomination indicated that Barry was trailing both Tucker and Washington. Barry himself delighted in casting himself as the decided underdog in the contest.

But Barry campaigned throughout the city as the candidate for mayor who would bring the most change to the District Building, Washington's city hall. He lumped Washington and Tucker together and claimed they represented the status quo. Barry frequently described his foes as the Washington-Tucker administration since they endorsed each other's candidacies four years ago when they were elected mayor and City Council chairman.

Here were the results as of 8:30 last night:

Barry 10,121

Washington 9,566

Tucker 9,387

In the race for the Democratic nomination for City Council chairman, Ward 4 councilman Arrington Dixon took a 3-to-2 lead over his chief rival, at-large councilman Douglas E. Moore. The Rev. John G. Martin, pastor of the Holy Comforter Baptist Church, trailed far behind.

In City Council races, school board member Betty Ann Kane took an early substantial lead over realtor H. R. Crawford in the race for the Democratic nomination for an at-large council seat. Seven other candidates were far behind, according to early returns.

In Ward 3, incumbent Polly Shackelton had clearly clinched renomination with a lead of more than 3-to-1 over challenger Joel D. Joseph.

In Ward 5, incumbent William R. Spaulding narrowly led Robert I. Artisst, a University of the District of Columbia professor. All other candidates in that eight-way race were far behind.

In Ward 6, incumbent Nadine P. Winter and realtor Patricia R. Press were battling neck-and-neck, with Winter holding a slim lead. Two other Democrats trailed far behind.

No results were available early last evening from Ward 1 because vote counting machines were used there and the votes were being counted separately. In that ward incumbent David A. Clarke is opposing three other Democratics for the nomination.

The only other council candidate up for reelection; Hilda M. Mason (Statehood-at large), was unopposed in the primary.

Del. Walter E. Fauntroy, the Democrat, who has represented the city on Capital Hill since 1971, was also unopposed in the primary.

In the Republican primary for mayor, Arthur A. Fletcher took a commanding 6-to-1 lead over Jackson R. Champion and appeared headed for that party's nomination.

All three Democratic mayoral candidates ran elaborate get-out-the-vote operations yesterday, complete with extensive telephone banks where campaign workers called voters who had been identified as supporters of their candidates to make sure they voted. Campaign workers and taxi drivers also ferried hundreds of voters to the polls.

Barry and Tucker workers complained of scattered irregularities in the voting, although the Washington campaign said it had found the election process working smoothly.

Harley J. Daniels, Tucker's campaign counsel, said Tucker's poll watchers had reported that some precinct captains overseeing the voting at the city's 137 precincts for the D.C. Board of Elections and Ethics openly urged voters to cast their ballots for Washington.

In addition, Daniels and workers for Barry charged that some independents and Republicans were allowed to vote in the Democratic primary, which is illegal under D.C. election laws. Daniels also said that one ballot box was left unattended in the street outside a Ward 3 precinct when a precinct captain apparently got tired of waiting for it to be picked up by election officials early yesterday afternoon.

Shari B. Kharasch, chairperson of the elections board, said the Tucker and Barry campaigns had made no formal complaints about the alleged irregularities.

She said it would be almost impossible for independents and Republicans to vote in the Democratic primary. Independents who tried to vote yesterday were told they could only vote in the Nov. 7 general election, while names of Republicans were called out with their party affiliation before they were given a ballot, she said.

One Tucker poll watcher, Yvette Parron, working in Precinct 84 on Capitol Hill, complained that a computer printout of registered voters there showed several persons listed twice, possibly allowing them to vote twice. City elections administrator Mary Rodgers acknowledged there still are duplicate registrants on city voting rolls. "We've tried to clean them out, but it's very hard to get them all," she said.

As election officials counted ballots at the Martin Luther King Memorial Library in downtown Washington late yesterday afternoon, a caller told a librarian that there was a bomb hidden in a drawer in the building. But Rodgers said there were no drawers in the area where the votes were being counted and so election workers were not evacuated. Library patrons were evacuated from 5:30 to 7 p.m., but a police dog sniffed through the building and found nothing.

The intense race for the Democratic nomination for mayor pitted three of the city's most prominent politicians against one another in a contest that was virtually devoid of sharp differences over the issues.

More so than in some other elections, this campaign was a test of political arithmetic. Tucker and Barry sparred to gain the lion's share of an anti-Washington vote that they felt represented the opinion of the majority of city voters. Washington, meanwhile, confident that he could be victorious in the three-way, winner-take-all primary with fewer votes than he received in 1974, tried to regain enough of his old support to eke out a victory.

Barry, the 42-year-old former codirector of Pride Inc., was the favorite candidate among whites in the city. He portrayed his two opponents as look-alike candidates who had failed to take the lead on major issues such as real estate speculation, unemployment, education and taxes.

Yet throughout the campaign, his efforts to gain support among key conservative and middle-class black voters was hampered by his former image as an outspoken black militant.

Tucker, the 54-year-old former director of the Washington Urban League, teamed his campaign with that of Fauntroy and council member Arrington Dixon, who ran for council chairman.

Tucker's campaign emphasized what he termed a need for change in city government, and was marked by a string of verbal assaults on the alleged inefficiencies of Washington's administration.

Washington, nevertheless campaigned on his record. "The 63-year-old former city public housing director told voters that he had been the one who had rebuilt the city from the ruins following the 1968 riots and had also laid the foundation for the District's current economic boom.

He said neither Barry nor Tucker had sufficient experience to lead the government during the next four crucial years.

The often bitter contest for council chairman offered voters in the city perhaps the clearest choice between candidates both on the issues and in terms of personal style.

Moore, the 50-year-old sharp tongued and controversial council member, campaigned as a self-proclaimed people's candidate. He painted Dixon as a pawn of the city's business community.

Dixon, a 35-year-old former computer science teacher at Washington Technical Institute, ran a low-keyed campaign, preferring to ride the cres of a wave of anti-Moore sentiment which at times showed him a more than 2-to-1 favorite of Democratic voters, according to many polls.

John Martin, the third candidate in the race, was always considered a long shot and his candidacy was largely ignored by his two opponents.