Like a flare in the night, the hijacking of a Pakistani airliner has suddenly lit up this country's domestic and foreign policy. President Zia ul-Haq is vulnerable to internal forces.

But he, and he alone, has the power to deal with the reality that makes Pakistan a front-line state in the competition between the superpowers. The Reagan administration, in formulating a strategy for the Persian Gulf and its environs, should deal with him accordingly.

At home, Zia rules illegitimately. He seized power in 1977, promising to restore law and order and then hold elections. The elections have been postponed repeatedly, and are now not even scheduled. The main political organization in the country, the Pakistan People's Party, or PPP, has been against Zia since he took over. Last month, the PPP won the support of eight other political groups for a campaign of resistance to force Zia out. oThe hijacking took place on the day scheduled for the start of the resistance campaign -- March 2.

Apart from lacking legitimacy, Zia has blood on his hands. He ordered the hanging of deposed prime minister Zulfika Ali Bhutto. The Bhutto family has sworn vengeance and converted much of the PPP into a party of revenge. The hijacking was led by a PPP member who acted in collusion with Bhutto's son, Murtaza. The hostage killed at the outset in a deliberately brutal murder was a former Bhutto aide suspected of betraying his master.

By those terroristic acts, the Bhutto family and their allies in the PPP have put themselves out of bounds as future rulers of Pakistan. The military, which commands ultimate power here, has rallied against the party and around Gen. Zia. So have many religious leaders who were on the point of joining the PPP in opposition. At least some PPP officials have also broken with the party. For example, Kamal Azfar, a former provincial minister under Bhutto and a socialist trained by Swedish economist Gunnar Myrdal, has been negotiating for a post in the government.

Foreign policy explains the surge of support for Zia. The Russian invasion of Afghanistan brought Pakistan face to face with the communist superpower. More than a million Afghan refugees have fled into this country. sSoviet planes regularly fly over the Pakistani border in hot pursuit of Afghan resistance fighters.

The Russians are also playing with radical elements in and out of the PPP to subvert the Zia regime. The hijackers took the plane first to Kabul, where they were protected by Babrak Karmal, the Soviet puppet leader in Afghanistan. Before continuing further, the hijackers boasted that they had been responsible for several terrorist actions in Pakistan, including the bomb explosion when the pope visited Karachi in late January.

The clear emergence of the Soviet peril has had an impact on Pakistani attitudes toward the United States. Officially, the country is still nonaligned. But the offer of military and economic aid, which was extended by the Carter administration and contemptuously dismissed as "peanuts," now looks a lot better. The Pakistani military in particular yearns for more modern aircraft. They also appreciate, far more than they did a year ago, the 1959 agreement whereby the United States gave Pakistan a kind of a guarantee against Soviet attack.

Attitudes toward India also show signs of changing under the threat of Russian pressure. Officially, the Indians are still Public Enemy No. 1, and the bulk of the Pakistani army is stationed to ward off attack from the east. But in conversations with me, several high-ranking Pakistani officials have privately wondered out loud about the possibility of reapprochement with New Delhi in a way that would rule out armed conflict.

They point out that India now has an interest in maintaining the security of Pakistan as a buffer against Russia. They assert that the disputed territory of Kashmir, in view of the absence of local resistance to Indian rule, no longer poses a serious problem. They say that India has an interest in better relations with Pakistan's close ally -- and Russia's bitter foe -- mainland China.

Conditions, accordingly, seem ripe for a new American move to cooperate with Pakistan in defense of common interests. But in making the approach, the Reagan administration will want to learn from the failure of the Carter gambit.

A first lesson is that aid negotiations should center on specific items rather than overall dollar figures. In that way, a lobby for agreement is built in the Pakistani military and there is no semblance of buying off the country by a bribe of so many hundred million dollars. A second lesson is that there be no dramatics such as the visit of Zbigniew Brzezinski to the Khyber Pass. On the contrary, quiet diplomacy is required for two items. One is the wooing of India. The second is an understanding that Zia move to legitimize his regime -- perhaps by standing for election as president.

Progress along these lines would undoubtedly come slowly. But the effort is worth the patience required. For the cooperation of Pakistan is an absolute condition for holding the line against Russia in south Asia, and an extremely useful adjunct to defense of the Persian Gulf with its vast stores of oil.