MIAMI (AP) _ Mayor Maurice Ferre, facing one of the toughest fights of his resilient political career, slipped behind Tuesday in his bid for a seventh two-year term, but appeared certain of a spot in a runoff.

With 65 of Miami's 85 precincts reporting unofficial returns, banker Raul Masvidal led with 23,759 votes, receiving support from many of the city's black districts. Ferre trailed with 21,579 votes, Harvard-educated lawyer Xavier Suarez had 18,679, and black educator Marvin Dunn had 11,443.

Percentages were not available due to reading machine failures.

''We have been saying all along in this campaign that Miami has to stand united, and the voters have today confirmed that,'' Masvidal said.

Ferre, 50, a native of Puerto Rico, faced 10 challengers, but only Masvidal, 43, and Suarez, 36, both Cuban-born; and Dunn, 45, were considered strong opponents. Suarez also ran against Ferre in 1983 for mayor of this ethnically divided city.

The seven other candidates were considerably behind, with less than 3,000 votes among them.

By late afternoon, turnout appeared especially high in heavily Cuban- American precincts, exit polls by Spanish-language television station WLTV indicated.

John Lasseville, a veteran Miami political analyst overseeing the station's polling, projected that 63 percent of all Cuban-born voters - representing 48 percent of all city voters - would cast their ballots, mostly for Suarez or Masvidal.

To win the non-partisan mayoral election a candidate had to collect a clear majority, or 50 percent plus one vote. Political analysts and polls suggested no candidate would reach that threshold, forcing a Nov. 12 runoff between the top two.

---

The mayor, who earns $6,000 a year, presides over the City Commission that runs the city but his vote counts no more than other commissioners'.

A poll conducted by The Miami Herald and WTVJ-TV and released two days before the election showed Ferre held a slim lead over Masvidal and Suarez.

Of the 273 registered voters polled, Ferre was the choice of 33 percent of those who said they were likely to vote. Close behind at 26 percent each were Masvidal and Suarez. Dunn was named by 8 percent of the respondents.

In this year's race, nearly all the candidates agreed about the issues - crime, economic development, deteriorating neighborhoods and the ''circus atmosphere at City Hall.''

But the most talked-about issue was Ferre himself. First elected mayor in 1973, he had to contend this time out with a decline in campaign contributions, disenchantment among blacks who supported him in 1983, and a rise in voter registration among Cubans who provided little backing two years ago.

His opponents charged he was responsible for dividing the multiethnic, racially troubled city and for the often-unruly atmosphere of the City Commission.

Much of the dissatisfaction among black voters stemmed from his casting a crucial commission vote in favor of firing Miami's first black city manager, Howard Gary.

On Monday, Gary filed a $6 million suit against Ferre over a campaign advertisement broadcast on two radio stations and claiming that Gary had ''received $150,000 to deliver the black vote for Raul Masvival.'' Ferre declined to comment on the suit, said aide Phil Hamersmith.

Ferre, who has often dubbed a ''Political Houdini'' over the years, conceded that he was a campaign issue. ''I accept that. I have a long record to run against,'' he had said.

He claimed that over the past decade, in which the city has seen an overwhelming influx of Cuban refugees and three racial riots, he had kept Miami sound financially.