The Soviet-installed Afghan government is attempting to gain popular acceptance here by stealing pages from the Iranian revolution's Islamic book.

The lessons of their neighbor's revolution apparently have not been lost on the communist leaderships in the Soviet Union and Afghanistan. While attacking the United States without pause, the Kabul administration of Babrak Karmal also has sought to identify itself with Ayatollah Ruhollah Khomeini's Islamic rule.

In a message to Khomeini that began, "In the name of Allah the compassionate, the merciful," Babrak this week assured the ayatollah that his government wants "full-hearted and cordial relations based on Islamic brotherhood with the Islamic Republic of Iran."

If the ayatollahs of Khomeini and the commissars of Babrak were to write a common textbook for revolution, some of the main points could well be:

Try to focus popular wrath, even after you have come to power, on a hated figure such as the shah or, in Kabul's case, the slain president Hafizullah Amin, to limit the chances that this wrath will rebound against the new government.

Blame everything that goes wrong on the United States, for much the same reason as above.

Invoke Allah at every available opportunity to justify your actions.

Appeal to public opinion by well-publicized releases of political prisoners, even though you may stock the jails with new ones of your own choosing.

When in doubt about what to do next, hold a mourning ceremony for compatriots martyred by the previous regime.

So it was that the People's Democratic Party of Afghanistan's new president Babrak, Monday organized masque ceremonies to mark a hastily declared National Mourning Day for Afghans killed under what is described here as the "sanguinary Amin regime."

Left unsaid by the new government is that many of the thousands of government opponents being honored and mourned were jailed, tortured or executed under the stewardship of the late president Nur Mohammed Taraki, who was overthrown by Amin last September and now is being portrayed as the country's number one martyr.

The main difficulty in trying to adapt Iranian revolutionary principles to circumstances in Afghanistan is that it is hard for leaders who are battling Moslem rebels to portray themselves as men of the cloth.

Somehow when Babrak invokes the phrase "bismillah irrahman irrahim" (in the name of Allah, the compassionate, the merciful) before a speech in which he effusively lauds the Soviet Union, there is an inherent contradiction that at least does not crop up when Khomeini speaks those words. c

At Kabul's Blue Mosque Sunday this was illustrated as party workers of Babrak's Parcham (Banner) faction of the People's Democratic Party encouraged mourners to sign "visitors' books" after filing through the mosque to hear plaintive Koranic chants in memory of the dead.

The well-drilled party cadres consistently denied that they were communists and gave the party line about how Amin, a leader of the party's rival Kalq (Masses) faction, was a CIA agent and tried to split the party in two.

One Parchamite, asked how he could reconcile the atheism of the group's Soviet sponsors with its staging of a Moslem religious ceremony, would only answer, "That's a good question."

Another organizer at the mosque, Abdul Ghafar Shergi, said he had joined the Parcham faction 10 years ago and had served three months in prison under the four-month rule of Amin.

"Babrak is acting for democracy," said Shergi, who now also works in the Agriculture Ministry. He added that the Afghan rebels opposed to the government were "Moslems in name only" and were really "working for the imperialist countries and the Saudis."

Then the gaunt, bearded Shergi, wearing a Russian-style fur hat, was asked whether it was apparent to him that Afghans dislike the presence of the estimated 85,000-strong Soviet force sent here to shore up the Babrak government.

"Maybe," he answered. "But they are not political people. They are simple people. They don't know who their friends are. They don't know who their enemies are. They are thinking by themselves."

The mosque-side chat with Shergi ended with this exchange:

"Are you a Moslem?"

"Yes of course. All Afghanistan is Moslem."

"Do you believe in God?"

"Huh?"

"Do you believe in God?"

A long pause. A smile. "No."

Inside the mosque, about 200 persons at a time sat on rugs under the building's dome to listen to the mournful five-minute sessions of chanting by a mullah. Then a new groups would file in between lines of Afghans holding their hands over their hearts in a melancholy reception line.

Visitors were told that those in the line had lost relatives under the Amin regime.

Party organizers of this and similar ceremonies acknowledged that government workers had been "encouraged" to attemd. Even so, the turnout did not seem overwhelming, with a few hundred people in and around the mosque at any one time.

Despite an order that shops close in observance of the mourning day, there seemed to be more Afghans in the neighborhood peddling food and sundries than attending the ceremonies.