MOST PEOPLE would probably tell you, if you asked, that immigration is the No. 1 issue between the United States and Mexico and trade No. 2. Yet in President Reagan's talk with Mexican President Lopez Portillo, trade was on a fast track and immigration on a slow one. If that sounds as though they had their priorities mixed up, it may not have been that way at all.

At last, the United States is seized of the problem of a massive annual flow of illegal immigrants, half or more Mexicans. A consensus for action had developed by the time of Ronald Reagan's election, and he was greeted by a balanced set of proposals -- amnesty for old illegals, tighter controls on new ones -- prepared by a national commission heavy with legislators of both parties. Mr. Reagan accepted the urgency and the need for balance. But he found the commission inflexible in addressing border-state employer demands for cheap labor. He has had a task force polishing a proposal for temporary or guest workers.

This is regrettable. Long experience in the United States (1942 to 1964) and Europe demonstrates that guest workers are an exploitable and indigestible subclass -- peons. Far from pre-empting illegals, they mark the path for them. The worksite-by-worksite regulation of the labor market a guest-worker program requires is formidable. In the atmosphere created by Mr. Reagan's casual embrace of the guest worker idea, however, border-state legislators led by Sen. Harrison Schmitt (R-N.M.) have surged ahead with legislation even before the president has worked out a common approach with the more nationally minded Sen. Alan Simpson (R-Wyo.), chairman of the key subcommittee.

Perhaps this was what led Mr. Reagan to take what was reportedly a tentative approach to immigration with President Lopez Portillo. On his part, the Mexican leader had scant incentive to press the matter since any new American immigration package imaginable will be more restrictive than the status quo. But the hesitation may not be for the worst. rThe chief factors governing both the push of migration from Mexico (and elsewhere) and the pull into the United States are economic. Trade, the item atop the Reagan-Lopez Portillo agenda, deals directly with these economic factors.

Immigration remains an unavoidable issue: no country in the world surrenders control over access to its territory as the United States does. But legislation is only part of the solution, whose wider dimensions are economic. On legislation, meanwhile, Americans and especially Republicans still have much to thrash out among themselves.