Several Punjab cities remained under curfew regulations today as state authorities tried to curb violence that claimed five lives yesterday and at least 25 others during the past two weeks.

Two demonstrators were killed by police fire in the state capital, Chandigarh, yesterday when 7,000 Sikh militants tried to storm the state legislature.

It was the worst violence ever in Chandigarh and represented a direct challenge by the militants to the moderate Sikh government of Chief Minister Surjit Singh Barnala, which came to power last September.

Nearly 200 persons have been killed in Punjab since Barnala took office after signing a peace accord with Prime Minister Rajiv Gandhi to calm Sikh-Hindu tensions following the June 1984 assassination of prime minister Indira Gandhi and the storming by the Indian Army of the Sikh's holiest shrine, the Golden Temple.

Most have died in attacks by extremists seeking an independent Sikh nation, but the increasingly systematic violence has also frequently involved Hindus.

The All India Sikh Students Federation and the extremist United Akali Dal, led by Joginder Singh, father of slain militant leader Jarnail Singh Bhindranwale, called a "black day" and closure of stores today to protest the killing of the two protesters. The Chandigarh raid sought the release of jailed Sikh youths and the reinstatement into the Army of those who deserted after the storming of the temple.

Barnala later criticized both the Punjab police and the Chandigarh administration for the incident and said that the situation would not have arisen if Chandigarh had been a part of Punjab.

Chandigarh is federally administered and serves also as the capital of neighboring Haryana. Under the terms of the accord signed last July between Gandhi and moderate Sikh Akali Party leader Harchand Singh Longowal, Chandigarh should have been transferred to Punjab on Jan. 26. But the transfer has not yet taken place.

"All this has weakened the Barnala government," said Rahul Singh, editor of the Chandigarh edition of the Indian Express newspaper, in an interview. "Yesterday's incidents again indicate that Barnala's government does not act firmly against terrorists," he said, and "people in the state are disappointed with his government . . . . Though Barnala is very firmly entrenched, the massive mandate with which his party came to power six months ago in September has definitely been eroded somewhat."

At least three more persons died in terrorist violence elsewhere in the troubled northwestern border state yesterday.

Schools, colleges and other educational institutions remained closed today in many parts of the state to prevent further violence during the protest called statewide by the Sikh students organization and the United Akali Dal. News agencies reported that the protest call evoked a limited response except in Amritsar, where shops around the Golden Temple complex stayed closed.

Sikh activists are maintaining control of the Golden Temple complex, where they are continuing the repair work on the temple under the flag of "Khalistan," the name of the separate Sikh state that many of them demand.

Batala has been under a curfew since last Sunday after violent clashes between local Sikhs and Hindus resulted in damage to places of worship. Since then the Sikh students organization has reportedly blocked all entry and exit points to the town, and the militant Hindus' Shiv Sena organization planned to send a group of 1,000 persons to "liberate" the besieged townspeople today.

"This is a new phenomenon," explained Rahul Singh. "Organizations like the Shiv Sena never commanded such support before. Communalism is on the rise and a direct result of the terrorist plan" to create fear among Hindus in Punjab to leave the state. The recent fighting also poses the new threat of organized Hindu-Sikh violence, where until now it has been sporadic and largely spontaneous.

Sikhs outside Punjab viewed the recent violence with concern. A Sikh officer with the income tax department of the central government said, "Each time a Hindu is killed in Punjab, we start to pray. They terrorists are making our lives very difficult," reflecting the fear among most Sikhs outside Punjab of a possible recurrence of the kind of anti-Sikh riots that took place in New Delhi and other cities after the assassination of Indira Gandhi.