TWO OF THE hundreds of legislators leaving town this weekend distinguished themselves by taking on a huge and heroic task and almost succeeding. Sen. Alan Simpson leaves for his home in Cody, Wyoming and Rep. Romano Mazzoli is heading for a reelection campaign in Louisville, Kentucky. They are an unlikely bipartisan pair whose constituencies have no special stake in immigration reform. But because each is chairman of the Immigration subcommittee in his house of Congress, each drew the leadership job -- and each rose to the occasion. We wish we could say the same of others, especially of those politicians and lobbies -- many liberal Democrats were among the worst -- who dedicated themselves to killing the bill for a variety of reasons that ranged from the flimsy to the sleazy. They succeeded, at least for now.

Both Sen. Simpson and Rep. Mazzoli have lived with this issue for years. Drawing on the 1981 recommendations of the Select Commission on Immigration and Refugee Policy, they introduced major reform legislation in the last Congress. The bill passed the Senate but died in the House in the closing days of 1982. This year, action was again swift in the Senate, but a series of roadblocks stalled final passage. First, Speaker O'Neill announced that he did not intend to call up the bill, only to relent last spring and provide time for five days of debate. After House passage and the political conventions, the bill's opponents sought to block a conference; once the conference met a deadlock developed over the question of job discrimination against aliens.

Mr. Simpson and Mr. Mazzoli were able to handle each crisis because of their practicality, commitment and good repute among their colleagues. They were persuasive with other legislators because they were fair, and because they tried to understand and accommodate their political interests and better arguments.

In the final hours of the session, the immigration bill died when conferees were unable to agree on a federal funding cap for programs aiding newly legalized aliens that was unwisely insisted on by the administration. Nevertheless, issues of enormous difficulty were settled. Both houses are now on record in favor of sanctions against employers who hire undocumented workers and an amnesty for those aliens who have been in this country for some years. Accord was reached on refugee policy, standards for continued legal immigration, procedures for deportation, the employment of foreign workers in agriculture, and a host of other difficult and emotional questions.

The chief sponsors led these negotiations and can be proud of what was accomplished. With enough time, they would have succeeded. Next time, they surely will.