JERUSALEM, AUG. 2 -- The Israeli government today adopted an emergency plan for housing thousands of immigrant Soviet Jews, but only after a cabinet dispute that confronted the right-wing coalition of Prime Minister Yitzhak Shamir with its first crisis.

Following a week-long debate, the cabinet decided today to import 9,000 prefabricated houses and 5,000 trailer homes to ease the severe housing shortage caused by the huge wave of Soviet Jews arriving in the country. It also agreed to allow private entrepreneurs to import 6,000 more prefabricated houses by the end of the year.

The decision represented a relatively modest response to a demand by Housing Minister Ariel Sharon that the government buy 90,000 imported homes and trailers during the next two years. Nevertheless, the move infuriated Finance Minister Yitzhak Modai, who has been arguing that the huge sums the government is spending on the Soviet immigrants threatens to wreck the country financially.

The mercurial Modai announced tonight that he is taking a one-month "leave of absence" from the government, and he disappeared from a session of parliament, together with the three other members of his political faction, called the Zionist Ideal. The move left the government, which took office in June with a parliamentary majority of only two votes, without a clear majority.

The crisis erupted just as the parliament was debating another key measure on immigration, a supplemental budget that increases spending by about $1.2 billion while cutting back on some government welfare payments and subsidies for consumer goods. Shamir's coalition managed to sustain its position narrowly with the help of a small religious party that is outside the government. The party, Agudat Israel, was given millions of dollars in funds for its projects in the new appropriation.

The cabinet's decision on housing followed the announcement of another large increase in immigration during the last month. According to official figures, 17,100 immigrants were registered during July, compared to 12,000 in June. Overall, officials said, immigration to Israel this year is near 75,000, including 65,000 from the Soviet Union.

The massive influx has caused a huge increase in housing prices around the country and prompted the creation of about 30 tent cities by thousands of native-born Israelis who say they have been made homeless. Sharon and other officials say that if the present rate of immigration continues, thousands more people will be living in tent cities, on army bases and in other impromptu quarters.

Modai argued that importing emergency housing for the homeless was less important than creating jobs. He warned that buying thousands of housing units abroad would drain Israel's currency reserves and raise the budget deficit to unacceptable levels. Israel's inflation rate is currently about 20 percent, but economists warn that the three-digit inflation the country experienced in the early 1980s could return.

Shamir outlined a series of budget cuts last week, but the government retreated on many of them by the time of the parliament debate today. In the latest compromise, Modai effectively agreed last night to forgo a $40 million cut in the military budget.