Israeli legal authorities ruled today that Prime Minister Yitzhak Rabin, who stepped down as his party's leader last week because of a scandal involving an illegal bank account, cannot resign as prime minister until a new government is formed.

The ruling means that Rabin, who had intended to turn his duties over to an interim prime minister, will continue to head the Israeli government at least until the May 17 elections and possibly much longer if expected problems develop in the formation of a coalition government.

Rabin was fined $1,500 today and his wife was ordered to stand trial for the joint accounts the couple illegally maintained in Washington after Rabin left the United States at the end of his tour as ambassador.

There was no immediate indication here of what effect the retention of a discredited prime minister in office might have on efforts toward a Middle East peace settlement.

Defense Minister Shimon Peres, who was chosen by the Labor Party yesterday to replace Rabin as its leader, cleared a major hurdle today in his efforts to hold together the fragile ruling coalition when he convinced the dovish Mapam Party to remain in the alignment.

The Mapam central committee decided by a close 159-115 vote to continue its 10-year association with Labor despite its previous threat to pull out of the coalition if Peres were chosen as Labors candidate for prime minister.

Peres, whom Mapam considers to be too rightiest and too hawkish, has been trying since Thursday to convince Mapam and the country at large that he is not a hawk and that he is committed to carrying out everything that Labor and Mapam had agreed upon. This includes, he says, a willingness to give up portions of the occupied territory for a peace pact and to oppose unauthorized Jewish settlements in the occupied territory.

Today Mapam decided to remain with Labor, but said its members were free to review the situation in six months to see if Labor and Peres have kept their promises.

Although Mapam holds only six seats in the present 120-member Parliament, their continued presence was considered by political experts to be vital both to their own political future and if the election is to be as close as everyone is predicting to the Labor Party as well.

Meanwhile, the main opposition party, Likud, said today that it intends to call a special session of Parliament to change the law to allow Rabin to resign.

Rabin had said Thursday that besides resigning as his party's leader, he would look into the possibility of turning over his duties as the head of an interim government to someone else. Technically, ministers in an interim government are not allowed to resign, but he thought there was the possibility that he could take a leave of absence.

After extensive discussions today involving Attorney General Aharon Barak, Justice Minister Haim Zadok, Deputy Prime Minister Yigal Allon and Rabin, it was decided that there was no constitutional or legal way Rabin could give up the responsibilities of his post until a new government is formed.

Although the election is to be held May 17, political experts say negotiations to form a coalition government could last anywhere from four to six weeks beyond the election date.

Rabin was prevailed upon today to agree to pay an administrative fine and allow his wife to be prosecuted on the bank charge, sources close to the prime minister said, because of the constitutional impossibility of resigning his post until after the election. His wife encouraged him in this decision, informed sources said.

Rabin's government resigned last December because it had lost a parliamentary majority and, according to Israeli law, Cabinet ministers must stay on at their posts in an interim government preceding an election.