The most serious coalition crisis of Israel's 19-month-old "national unity" government ended tonight with a simple Cabinet portfolio reshuffling that removed the rebellious finance minister, Yitzhak Modai, from his job.

After an anticlimactic, 15-minute Cabinet meeting, Prime Minister Shimon Peres announced that Justice Minister Moshe Nissim would replace Modai and that Modai would assume the Justice portfolio.

The compromise defused a coalition standoff that threatened to bring down the fragile alliance between the Labor Party and the Likud bloc and lead to early elections.

The agreement represented a major victory for Peres and a setback for the Likud ministers, who had demanded that if Modai were removed from his post, he should at least be allowed to regain his portfolio after the scheduled Oct. 25 rotation of the premiership between Peres and Foreign Minister Yitzhak Shamir.

The Likud Cabinet members had threatened to resign as a bloc if Modai was not guaranteed a return to the Finance Ministry on Oct. 25. Their resignations would have forced a collapse of the government.

Under the compromise announced by Peres late tonight, Nissim will be finance minister and Modai will be justice minister throughout the term of the coalition government, which expires in 1988.

Obviously pleased by the outcome, Peres told reporters, "I do believe the whole story ended up to my satisfaction." When asked if he was completely satisfied, Peres replied, "Say ninety-nine percent. But I think it basically satisfies my demands."

The coalition crisis erupted two weeks ago when, while Peres was visiting the United States, Modai, in two Hebrew newspaper interviews, accused the prime minister of squandering money on Labor Party-affiliated enterprises and of engaging in a "cynical game with the resources of the state." Modai also criticized Peres' travels, calling him a "flying prime minister."

Peres countered by demanding Modai's resignation as finance minister, although he said Modai could remain in the Cabinet with another portfolio.

On Friday, the crisis appeared to have evaporated when Peres agreed to allow Modai to trade jobs with Shamir for the next six months. However, that compromise ran into a snag when the Likud ministers rebelled and insisted that Modai be allowed to return to the Finance Ministry after the rotation in October.

The coalition crisis was the latest of more than a half-dozen that have threatened the fragile alliance forged in September 1984, after neither the Likud nor the Labor Party won a majority in parliamentary elections.

Following a nine-hour meeting of the Likud members of the Knesset (parliament) today, the party's Cabinet ministers agreed to the portfolio trade, which offered the face-saving provision of retaining the top Finance Ministry post within the Liberal Party faction of Likud.

Nissim, who has been justice minister since former prime minister Menachem Begin rose to power in 1977, is a member of the Likud-allied Liberal Party.