U.S. District Judge Gerhard E. Gesell voiced clear sympathy yesterday for Marion Barry's desire to keep his seat on the D.C. City Council while running for mayor. But Barry will have to wait a while for a ruling.

Repeatedly during oral arguments Gesell questioned what purpose is served by requiring one group of District of Columbia officeholders to quit their positions to run for higher office, yet letting others keep their offices while seeking other posts.

"Don't you think it would be right to treat everyone the same?" Gesell asked at one point. "That's the problem, isn't is?"

Yesterday's arguments were on Barry's lawsuit seeking to overturn a provision of the congressionally enacted D.C. Home Rule Charter that requires Barry to step down to conduct his mayoral race. If the law is upheld, the deadline for his resignation is July 5.

The provision states that no elected city official may run for another city office unless his present term expires before the beginning of the term of the job being sought. Barry's council term expires in 1981. The next mayoral term begins next January.

Gesell, saying he expects the losing side to appeal his decision, said he "will have a ruling as promptly as possible.

Barry's suit is opposed by the D.C. Board of Elections and Ethics, the defendant in the case: by D.C. Corporation Counsel John R. Risher Jr., who said he is required to defend the constitutionality of any city law, and by JePhunneth Lawrence, a lawyer who said he wants to run for Barry's council seat.

Albert J. Beveridge III, Barry's lawyer, said a search of congressional documents has disclosed no reason why the resignation provision was included in the charter.

As a result of staggered terms on the council, Beveridge said, the holders of six of the 13 council seats - including Barry - could never run for mayor or other higher office without resigning, while incumbents in six other seats could keep them while running for identical higher offices. The 13th council seat is that of the chairman, whose term is the same as the mayor's.

Gesell observed that those who are required to resign became victims "of the roll of the dice" when the timing of the staggered terms was determined.

Winfred R. Mundle, general counsel of the Board of Elections and Ethics, argued that the resignation requirement keeps council members more attentive to their jobs and benefits the city.

He also said Barry could retain his seat beyond July 5 if he chose to run as an independent or a write-in candidate, rather than seeking the Democratic nomination.

"Not if he wants office," Gesell replied. "If he wants office, he wants the nomination of one of the two major parties. I would think it would be beneficial to have the Democratic nomination . . . he's a Democrat."

While James C. McKay Jr., an assistant corporation counsel, was arguing the city government's case, Gesell stressed that this forthcoming decision would affect all candidates in the future, adn not just Barry. "Mr. Barry is (only) a manifestation of the operation of the statute," the judge said.