Former Mayor Frank L. Rizzo collapsed and died of a heart attack today just months after staging a comeback with an upset victory in the Republican mayoral primary. His death leaves the Republicans without a candidate at a time when the rules for replacing candidates are under litigation in Federal court here.

Mr. Rizzo, 70 years old, was stricken at lunchtime during a routine day. An aide found him collapsed on the floor of a bathroom at his downtown campaign headquarters, and after efforts to revive him failed, he was taken to Jefferson University Hospital. He was pronounced dead at 2:12 P.M.

The former Mayor was one of the most dominant political forces in this city for a quarter century, and his death creates a vacuum in leadership for about the third of the city's electorate -- mostly older, white, ethnic working-class voters. He ran as a Democrat in his first three mayoral campaigns and as a Republican in this one and in 1987. 2 Mayoral Victories

Mr. Rizzo, who rose to prominence as the city's Police Commissioner during the racially turbulent 1960's, was first elected Mayor in 1971 and then again, by a landslide, in 1975. Throughout his tenure as Commissioner and Mayor, there were persistent charges of racism and police brutality.