A behind-the-scenes compromise yesterday unexpectedly resurrected the massive immigration reform bill, and supporters said they will try to rush the measure to passage next week, before the Congress quits for the rest of the year.

Rep. Romano L. Mazzoli (D-Ky.), a chief sponsor of the controversial bill, acknowledged yesterday that the legislation was racing the clock and House uneasiness about voting on it again.

But he said he was optimistic that a House-Senate conference scheduled for 2 p.m. Tuesday would approve the compromise and bring the bill to the Senate and House floors for votes before Congress adjourns, probably next week.

"This is a balanced package, and it deserves to come to the floor," he said. The bill has been considered all but dead for the last week, when the conferees stalled over an antidiscrimination provision in the bill and called off further negotiations.

Congressional Hispanics, who have opposed the measure as too restrictive and likely to produce job discrimination against Hispanics, were taken aback by the unexpected announcement of a compromise, and said they will redouble their efforts to kill the immigration bill.

"Proceeding at the midnight hour . . . will create chaos and a bad bill," said Rep. Bill Richardson (D-N.M.), chairman of the Hispanic caucus.

The measure is designed to stem the flow of illegal immigrants into this country by imposing stiff criminal and civil fines against employers who hire illegal workers. The legislation also would legalize the status of millions of aliens who crossed the border and have lived in the United States illegally since 1981 or earlier.

The only provision left unresolved by the conference committee when it disbanded was the antidiscrimination language written by Rep. Barney Frank (D-Mass.).

Mazzoli said Sen. Alan K. Simpson (R-Wyo.), the bill's chief Senate sponsor, and Frank reached a compromise yesterday afternoon, just before the Congress recessed for the long Columbus Day weekend.

Frank and Simpson could not be reached for comment yesterday.

The dispute involved Frank's insistence that a legalized alien may sue or seek governmental redress if an employer chooses to hire a U.S. citizen over the alien. Opponents also objected to what they described as a cumbersome and undesirable special office in the Justice Department to investigate and prosecute employers who violate the provision.

Under the compromise worked out yesterday, persons "intending" to be citizens would have the same rights to protection against discrimination as citizens, and the special office in the Justice Department would remain intact.

Rep. Charles E. Schumer (D-N.Y.), who drafted the compromise, said yesterday that "time is running out" but added that the bill could move through Congress and be sent to President Reagan in as little as 24 hours under expedited procedures.

However, for the legislation to survive, it would have to clear a daunting obstacle course of at least one vote in the Senate, where conservatives have threatened to filibuster the bill, approval by the House Rules Committee, and possibly two votes on the House floor, where the bill was approved last spring by only a five-vote margin after heavy lobbying against it by organized labor, some business groups and Hispanics.

If it survived that process, the measure would go to Reagan.

Simpson said last week that Reagan indicated he would approve the legislation if it included a ceiling on costs.

Mazzoli said that as part of the compromise worked out yesterday the conferees would write into the statute that only $1 billion a year could be spent during the next four years to reimburse states and localities for the cost of the legalization program.