PITTSBURGH (AP) _ An incumbent mayor who likes to be called a ''Jewish grandmother'' beat back four challengers Tuesday in the Democratic primary, giving her an almost sure ticket to victory in November.

''Thank you to all of Pittsburgh,'' Mayor Sophie Masloff said. ''I accept this victory with deep appreciation and humility.''

Mrs. Masloff, 71, known as ''Sophie'' around the city, was City Council president last year when she was appointed to fill the vacancy left by the death of Mayor Richard S. Caliguiri.

With 394 of 402 precincts reporting, Mrs. Masloff had 29,994 votes, or 28 percent, to 24,766, or 23 percent for state Rep. Thomas J. Murphy Jr.

The man who had been considered her main challenger, Allegheny County controller Frank Lucchino, trailed with 22,616 votes, or 21 percent.

Byrd R. Brown, an attorney who led the local NAACP branch during the 1960s, and City Controller Tom Flaherty, who had the local party endorsement, split the remainder.

''We're a family and we just had a good talk about the future,'' Mrs. Masloff said of the campaign and her opponents. ''We all learned a lot. ... These are good and serious people and I salute them.''

Mrs. Masloff's challengers conceded defeat well before midnight Tuesday. None said he planned to run as a Republican or independent against Mrs. Masloff in November.

---

Caliguiri, who died of the rare heart disease amyloidosis in May 1988, was mayor for 11 years, twice winning re-election by landslides.

The Democratic winner is all but certain to win the November election. Democrats represent 82 percent of the city's 220,069 voters. The Republicans have not elected a mayor since 1933 and no GOP candidates were in the primary.

Mrs. Masloff, who uses the ''Jewish grandmother'' tag as part of her folksy image, has been a Democratic loyalist for more than 50 years.

Lucchino, 50, a lawyer and a longstanding party leader who is serving a third term as county controller, was Mrs. Masloff's main rival in the polls, although surveys showed his support waning in the last month.

He had the support of the city's two daily newspapers and reportedly spent more than $1.2 million on his campaign, more than twice that spent by Mrs. Masloff.

Issues included the contenders' political personalities, economic development and jobs, the city's 3.5 percent wage tax on residents, a 10 percent amusement tax, crime prevention, neighborhood renewal and gay rights.

Pittsburghers also voted for Democrats seeking nine nominations to City Council under a new district set-up replacing the current at-large system.

Black leaders hope the new districts will deliver two blacks to the Council.

EDT