U.S. national security adviser Zbigniew Brzezinski and Pakistani President Mohammed Zia ul-Haq held more than seven hours of talks today, but failed to reach final agreement on a new aid and security framework the two countries have sought since the Soviet invasion of Afghanistan.

The two delegations are scheduled to meet again Sunday, however, and both men indicated in toasts at a dinner tonight that the wide breach that divided the two former allies now has been at least partially healed.

"It is heartening to see our traditional ally, a country for whom Pakistan has lots of love and regard, the United States of America, giving us the impression of finding a lost Asian ally," Zia said.

His remarks stood in sharp contrast to comments he made during the past six weeks calling Pakistan's former close relationship with the United States "a bitter experience" and saying American had proved itself to be an unfaithful friend and undependable ally.

Alluding to those remarks and feelings, Brzezinski replied. "A friendship restored is often a friendship invigorated." Nevertheless, he pointedly referred to "differences that create obstacles" for greater understanding.

"We must not let small obstacles paralyze the needed progress," said Brzezinski, who heads an American delegation that includes Deputy Secretary of State Warren Christopher and Assistant Secretary of Defense David McGiffert.

The high-level talks headed by Zia and Brzezinski were scheduled to be concluded today with Sunday reserved for a symbolic trip to the Khyber Pass at Pakistan's border with Afghanistan and to Afghan refugee camps in the Northwest Frontier Province. But the tour was cut short, and talks will continue Sunday afternoon.

It was unclear tonight why and how badly the talks were stalled. Both sides refused to talk and Zia postponed an interview he had scheduled with a half-dozen American reporters traveling with Brzezinski.

The Americans issued a short statement saying, "Since both sides wish to examine various aspects of these discussions in greater detail, the talks will continue tomorrow."

As it was, the discussions lasted longer than scheduled. They ended after 8 p.m. -- just before Zia's dinner for the delegation.

One possible snag is the amount of aid the United States is prepared to give Pakistan. Administration sources said the initial U.S. contribution will be $400 million -- half military, half economic -- over the next two years.

Zia once referred to that amount as "peanuts," and said it would not meet Pakistan's security needs while provoking anger from both the Soviets on the western border with Afghanistan and India on the east.

Pakistan has accused Washington of failing to support it in two wars with India since the neighboring countries were carved from British India and given independence 32 years ago.

The strains were worsened last April when the United States cut all aid to Pakistan over its nuclear program, which American said was aimed at building atomic weapons -- a charge Zia denies.

Nonetheless, all was cordial during the dinner, held at the presidential guest house in the neighboring city of Rawalpindi. Remarks were not expected, but Zia stood up at the end to deliver the most optimistic assessment he has made of U.S.-Pakistani relations since the Soviet-backed coup in Afghanistan Dec. 27, forced his country to the center of Western security concerns.

"I hope in the process of our meetings to find the old, traditional ties that were not quite snapped but had undergone strain" Zia said. "I hope Dr. Brzezinski will help us mend those . . . ."

Zia then toasted President Carter's health and, in a unusual foray into American domestic politics, offered "very good wishes for him and a very successful election campaign."

Brzezinski, in his reply, said the United States wants to help the nations of southern Asia and the oil-rich Persian Gulf region protect their independence and integrity from the increased threat of the Soviet Union as a result of its takeover of Afghanistan.

"We are here not to increase tension, but to promote security," added Brzezinski, in an obvious reference to India, which has been telling the United States that rearming Pakistan will worsen the strategic situation in the region.

Obviously buoyed by the overwhelming condemnation of the Soviet invasion of Afghanistan by the Islamic foreign ministers' conference here earlier this week, Brzezinski said the United States welcomed the resurgence of the Islamic world.

"We in the United States," he said, "neither fear nor deplore, but welcome the Islamic renaissance."