Pakistan staged its first full-fledged Independence Day celebration in 25 years today in an apparent bid by the martial-law government to foster national unity.

Although the celebration took place by fiat of President Mohammed Zia ul-Haq, it appeared that Pakistanis were taking the anniversary to heart in this city -- the largest in Pakistan -- and elsewhere across the country.

The government had ordered all traffic to stop at 9 a.m. so that people could get out of their vehicles and sing the national anthem. Compliance was not 100 percent, but so many cars, trucks, scooters, taxis and horse-drawn carts were decorated with the national flag that the celebration looked like a joyous and spontaneous affirmation of patriotism.

Pakistan was carved from British India to become an independent Moslem state 34 years ago this midnight. India, which gained freedom from British rule at the same time, will celebrate its Independence Day Saturday, when Prime Minister Indira Gandhi will give what is expected to be a major speech at Delhi's Red Fort.

Today in Pakistan, Zia's government appears more firmly in control of the country than at any time since the Army took power slightly more than four years ago.

Civilian political activity, banned by Zia almost two years ago when he canceled elections but until recently carried on clandestinely, appears to have ground to a halt.

Most civilian politicians have been released from jail, where many were put in March and April, when Zia used the hijacking of a Pakistani jetliner as the vehicle to nip an embryonic movement demanding free elections. The most prominent political figure still jailed is Benazir Bhutto, the firebrand daughter of former prime minister Zulfiqar Ali Bhutto, whose Pakistan People's Party is considered the best organized and most popular in the country. Her father was executed by the Zia government for conspiring to murder a political opponent.

Despite their freedom, however, politicians in Karachi, in the politically active city of Lahore and in the capital of Islamabad have remained quiet. A few tried to hold a meeting a month ago, but Zia's security forces arrested 19 of them.

"It's so quiet it's sickening," said a Pakistani journalist. In Lahore, said a close observer of the political scene, "Zia is the only thing going on in politics right now."

Even some of Zia's more vociferous opponents in Islamabad, men who have been predicting regularly during the past two years that his government will fall within six months, now are resigned to his remaining in power. A well-informed Lahore businessman, bitterly opposed to Zia, now concedes that he is here for the forseeable future and believes that Army rule will continue for at least another 10 years, even though Zia may be replaced by another general.

Nonetheless, many Pakistani and Western observers believe Zia lacks charisma and has not captured the popular fancy to the extent that would be needed to win a free election.

He has outmaneuvered the civilian politicians at every turn, however, and most of them are now considered powerless. At the same time he has adroitly played the only political game that really matters -- within the Army -- to make sure he is not removed by some of his fellow generals.

It is unclear why Zia decided to make Independence Day a major event this year after the anniversary had been left uncelebrated -- although it was a holiday -- since 1956, when Pakistan's constitution took effect. Pakistan's national day, which commemorates that event, is in March.

Even government officials offered no good explanation for the president's decision, which was announced suddenly about 10 days ago.

Many believe that the mandated celebration is designed to win more popular support for Zia by associating him with the most important event in the nation's history.

One knowledgeable Western diplomat suggested that Zia is using Independence Day as one element in his attempt to create a national ethos for Pakistan, which in its 34 years of existence has been bedeviled by regional rivalries.

Furthermore, the celebration could rejuvenate Pakistani nationalism at a time when 85,000 Soviet troops are in Afghanistan, just across Pakistan's western border, and Indian officials are citing "war clouds" in the region because Pakistan has entered into an arms-purchase agreement with the United States.

Along with today's festivities, Zia ordered that the national flag -- a Moslem crescent and star on a green background, with a white border -- be flown from all residences and commercial buildings.

This is a sharp break with tradition. Under Pakistani law, inherited from the British, the flag can be flown only at the residences of high-ranking officials and on government buildings. Minor officials have lost court cases in which they have sued for the right to fly the Pakistani flag on their cars or in front of their houses.

Flying the flag appeared to be the most popular manifestation of the day.

"My children are very happy at this," said an Islamabad father. "They see American movies on TV that have flags in front of houses and want to know why we can't fly ours."

Zia opened the day by hoisting the flag in front of the presidency, a Victorian building in Rawalpindi, in a ceremony that was televised live throughout the nation. Similar ceremonies took place in provincial capitals, and in small cities local officials staged events that sounded as if they came from a handbook of American Fourth of July or Memorial Day celebrations.