The United States has offered Pakistan $400 million in economic and military assistance over the next two years in response to the threat posed by the Soviet takeover in neighboring Afghanistan, State Department officials said yesterday.

The aid package was disclosed to Pakistan's top foreign affairs adviser, Agha Ahahi, in meetings here Saturday. It will be Washington's share of an international effort that is expected to be broadly based, encompassing the People's Republic of China and Persain Gulf oil-producing countries as well as Western European nations.

Several key members of Congress were informally notified of the aid plan yesterday, and officials said the administration will be ready to defend the program when Congress returns to town next week.

A special congressional act will be required to override the effect of existing laws aimed at curbing the proliferation of nuclear weapons. The United States cut off economic and military aid to Pakistan under the anti-proliferation laws last April because of evidence that a secret plant is under construction near Islamabad.

In Saturday's discussions, the Pakistanis reportedly gave no indication of a change of policy toward their uranium enrichment plant, although intelligence reports indicate that work on the facility is proceeding slowly because of technical problems. Officials said the United States repeated its concern that the spread of nuclear weapons in the areas will bring new dangers to Pakistan and other nations.

Details of the aid program remain to be worked out by technicians in Islamabad and Washington.

As of now, according to official sources, the program is expected to incude:

Military sales credits of $200 million spread over two fiscal years, largely for the purchase of antiaircraft and antitank weapons and other equipment for the defense of the porous northwest frontier which borders on Afghanistan. There is no likelihood at this point of U.S. sales of high performance aircraft which Pakistan has requested in the past, but which could be a trheat to India.

Economic aid of $200 million over two fiscal years, including fertilizer and other goods which could be quickly felt in the Pakistani economy.

The United States has continued to supply about $40 million in food aid, despite the cutoff of other assistance. This will continue and may be expanded.

Officials said the Carter administration is also considering a Pakistan-generated plan to stretch out repayment of that country's large foreign debt. No decision on this question has been reached.

In another action of help to Pakistan, the Carter administration has agreed to increase its aid of a United Nations program for Afghan refugees who have streamed across the Pakistani border. More than 400,000 refugees have already arrived, and several thousand more come each day. The $5.5 million in emergency relief funds, about one-third of the United Nations total, and more funds will be needed, officials said.

Sen. Edward M. Kennedy (D-Mass.), chairman of the Senate Judiciary Committee and chief Senate sponsor of most refugee legislation, said yesterday he will ask Congress to provide at least $60 million to meet urgent needs of Afghan and Somalian refugees. Kennedy said the Afghan refugee total in Pakistan could swell to 900,000 if the fighting in Afghanistan grows.

In justification for the renewed aid program for Pakistan, State Department spokesman Hodding Carter said that "the Soviet Union has created a destabilizing situation where Pakistan, with good reason, can feel threatened. Our response, in the first instance, must deal with that situation."

He went on to suggest that other nations in the area also face new peril. "Since we don't know why the Soviets invaded Afghanistan, we Can't rule out a second, or third, or fourth operation against other countries," he said.