Massachusetts Democrats are embroiled in a bitter political fray sparked by right-wing Edward J. King's upset primary victory over liberal Gov. Michael S. Dukakis.

The shock of a conservative victory in the only state to vote for George McGovern in 1972 has created a defection of Democrats that should help Republican gubernatorial candidate Francis W. Hatch, the moderate Massachusetts House minority leader.

"The party is in about the same shape as the Holy Roman Empire - it's in a shambles," said Barney Frank, a now-repentant liberal Democratic legislator from Boston who led the "Dump The Duke" drive against Dukakis.

In defeat, the anti-pork barrel governor, whose fiscal conservatism and spartan managerial style caused liberals to become disaffected early in his term, now has been elevated to a sacrosanct position in political post-mortems.

Stunned by the primary results, many of the party's liberals - including Barbara Ackerman, who got 7 percent of the vote in the primary, and leading fund-raiser Gerome Grossman - choked at the prospect of supporting King, who in the wards of one aide "put all the hate groups into one pot and let it boil" in soundly defeating Dukakis on a handful of emotional issues.

In an effort to quell dissension within the party, House Speaker Thomas P. (Tip) O'Neill Jr. (D-Mass.) - whose son, Lt. Gov. Thomas P. P'Neill Ill, is King's running mate -is touting the banner of party unity to bring liberals back into the Democratic fold.

The White House, prompted by the speaker and fearing the loss of the Massachusetts statehouse, also has become entangled in the political drama here.

In a call to arms by Speaker O'Neill, President Carter telphoned Dukasis to persuade him to endorse King.

But the one-term governor balked at supporting King on ideological grounds, claiming he has failed to show "a commitment to the principles of the Democratic Party."

Party unit notwithstanding King's ideology also has meant flagging support for his candidacy from the president, sources said.While publicly pledging support for the entire state Democratic ticket, White House aides were quoted in the newspapers here as calling King "a turkey."

The president is "figuratively holding his nose over King's presence on the Democratic ticket," said one report. The comments were attributed to several White House aides.

Presidential assistant Timothy Kraft promptly apologized, calling the remarks "totally inappropriate." Added King's press secretary, Martin Burke III, the comments were "inaccurate, unfair and distasteful . . . to say the least."

"The president may have varing positions on the issues with some Democrats," Kraft said, "but we're not going to get into a calibration on how many issues we agree with or disagree with before we offer our support."

Meanwhile, efforts in Massachusetts by leading Democrats have failed to convince King to soften his positions on the issues that brought him victory and drove away the liberals - anti-busing and abortion, pro-capital punishment and tax-cutting measures fashioned after California's Proposition 13.

"We've had a unity breakfast and a unity brunch," King said after a meeting with Speaker O'Neill and other Democratic candidates. "Maybe lunch is next."

King, a political rookie who ran the Massachusetts Port Authority and led a business lobby. The New England Council, maintains he is in the "political mainstream" and that he will win the election with or without the support of Dukakis and the liberals.

He might be right, observers here contend, as long as he has O'Neill behind his candidacy andO'Neills son on the ticket.

"Tommy is the only cement binding this whole campaign together. Many people are going to come over to King because of the O'Neill," said Frank.

The younger O'Neill, mentioned by national Democratic Party chairman John White as a rising national political star, found himself in the precarious position of running with a political opposite after four years with Dukakis.

"Diversity is the hallmark of the Democratic Party," he said. "We don't agree on the issues, but I can run with him. King knows firmly where I stand, It's a line I've drawn, and I will not compromise my beliefs or my integrity."

For his part, Dukakis said he "fundamental differences" with King will be difficult to resolve before Nov. 7 - even at the behest of the president.

"Carter understands my position," Dukakis said. "After all, he ran for governor and lost to Lester Maddox.He know what I face is this kind of [TEXT OMITTED FROM SOURCE]