Patricia Roberts Harris, a former Carter administration cabinet member and U.S. ambassador to Luxembourg, yesterday ended months of speculation by filing as a candidate for D.C. mayor in the Sept. 14 Democratic mayoral primary.

Harris, 57, is viewed by many political observers as potentially the strongest challenger to Mayor Marion Barry, primarily because of her national prominence. However, the other announced Democratic candidates for mayor insisted yesterday that Harris' entrance in the race would in no way affect their campaigns.

Harris has informally canvassed the city's political landscape since December, visiting homes and churches to meet voters while saying she was considering running for mayor.

Harris, who was in New York yesterday for an IBM board meeting, said in a prepared statement she intends to formally announce her candidacy on March 20.

"For the last two and a half months," the statement said, "I have enjoyed sharing my experiences and my vision for this city with people from all income levels--all walks of life--and I am grateful for their willing, open hospitality.

"I honestly wanted to be sure my problems, concerns and hopes for the District matched those of others and they do. I believe I can make a difference by bringing effective administration to this city. Therefore I am offering myself as a candidate for mayor of the District of Columbia."

Harris, who headed the departments of Housing and Urban Development and Health, Education and Welfare under President Carter, filed with the D.C. Board of Elections and Ethics the morning after former City Council Chairman Sterling Tucker announced that he would not be a candidate for mayor. Tucker, who barely lost the 1978 Democratic mayoral primary, had been expected to challenge Barry this year.

Tucker's withdrawal and Harris' entrance into the mayor's race appears to lay the groundwork for a two-way battle for the Democratic nomination between the mayor and Harris.

Tucker's supporters in the last election were middle- and upper-income black families, many with deep roots in the community. It is a constituency that could transfer its allegiance to Harris. Yesterday, Tucker said he intends to endorse either Harris or Barry, but declined to say which candidate.

"I've made absolutely no decision," said Tucker who spent most of the day at the office of his Connecticut Avenue consulting firm, Sterling Tucker Associates, taking calls from friends and former supporters.

Tucker, who went to the Department of Housing and Urban Development (HUD) as an assistant secretary to Harris after losing in the 1978 primary election, met with Barry last week before deciding against entering the race. He said yesterday that he hasn't ruled out endorsing Barry.

Tucker did say that if he had remained in the race he would have shared support with Harris: "Her polls and mine probably would show we draw from the same people," he said. "Just like Walter Washington and I drew from the same group in 1978 and canceled each other out."

Tucker predicted that Harris would do as well as he and former mayor Walter Washington did in Wards 4, 5 and 7. Those are the three largest Democratic wards in the city, and between them Washington and Tucker drew enough votes to win all three. "That's a big bloc of votes," Tucker said.

During a candidates' forum sponsored by the Gertrude Stein Democratic Club Monday night, Tucker said he was withdrawing because the field of candidates was now so large that it had created a "battle of personalities" that would obscure debate of serious issues. He said it would also make it difficult for the next mayor to win the election with a clear mandate from the voters.

In the 1978 race Tucker lost to Barry by about a 35 percent to 32 percent margin, with Washington receiving about 30 percent of the vote.

While Tucker predicted a Barry-Harris race for mayor, other Democratic candidates who have filed for the mayor's race--council members Betty Ann Kane, John Wilson and John Ray--said Harris' announcement will have no effect on their campaigns. The mayor refused to make any comment on Harris' entering the primary.

"The incumbent is always the favorite," said Sharon Dixon, Harris' campaign manager and a national Democratic committewoman. "She understands that . . . this will be a hardworking campaign. We have the basics of an organization in place. If we didn't, she wouldn't be running.

"Mrs. Harris is a very cautious and careful person and she wants very much to be mayor. She is approaching this campaign as she would approach serving as mayor, with an eye for the big picture but an appreciation for detail," Dixon said.

Also filing in the mayor's race yesterday was Dennis Sobin, 38, publisher of MET Forum, a newspaper that features sex-oriented personal ads. Sobin said law enforcement would be a major theme of his campaign.