When the Sikh religious party, the Akali Dal, takes power in India's troubled Punjab State Sunday, it will begin a delicate political balancing act -- implementing a compromise settlement of longstanding Sikh demands while controlling Sikh militants and terrorists who want to scuttle the compromise.

With today's final results from Wednesday's election giving the Akalis 73 of the 115 state assembly seats, the party prepared to take power from the central government, which has ruled the state directly for two years. In the Punjabi capital, Chandigarh, newly elected Akali legislators today named 59-year-old Surjit Singh Barnala as the state's next chief minister. Barnala was elected unanimously in an apparent submersion of factional differences in the Akali leadership.

Barnala, the party's acting president, was a close confidant of Harchand Singh Longowal, the Akali chief who was slain by Sikh extremists after he signed July's compromise agreement with the central government on long-standing Sikh demands for more political autonomy and economic rights.

The Akali victory was widely hailed as a popular endorsement by Sikhs of the July agreement and as a repudiation of extremists who sought to scuttle both the agreement and the election.

Prime Minister Rajiv Gandhi today thanked "the brave and patriotic people of Punjab for demonstrating yet again the enduring strength of democratic institutions in India." The voters, he said, had "blessed the accord" between Longowal and the government.

But, as important and necessary as the Akali victory is for ending the communal violence that has killed more than 2,000 people in three years, even optimistic observers agree that the danger of Sikh extremism and terrorist violence will continue. As the new Akali government tries to gain effective political control during the coming months, it will face the reemergence of several difficult issues that were postponed, rather than resolved, by the July agreement.

In the election, the mainstream of the Sikh community appeared to have expressed its exhaustion with the cycle of violence that has disrupted the state's life and economy. But the campaign also showed that Punjab's young, educated Sikhs, many of whom are unemployed and disaffected, continue to form a recruiting ground for the extremists.

The terrorists who killed political figures during the campaign were almost invariably described as young men, and youthful Sikhs interviewed over recent weeks expressed admiration, if not support, for extremist leaders.

"It needs to be grasped that extremism in Punjab now has a significant mass base," according to Chandan Mitra, political columnist for The Statesman newspaper. "The less affluent Sikhs . . . are, in many cases, sympathetic to the extremist cause," even if they may have voted for the Akali Dal.

A strong showing by a militant woman candidate, the widow of the Sikh bodyguard who assassinated former prime minister Indira Gandhi, suggested that extremists may still be able to use emotional symbols to generate support within a wider segment of the community.

The July accord simply postponed the resolution of several of the most emotional Sikh demands until next year. When those issues reemerge for final arbitration, the hard-liners will have a new opportunity to argue against further compromises by the moderate Akali government.

A commission appointed by New Delhi will rule on Sikh demands for the transfer of predominantly Sikh villages from the neighboring state of Haryana to Punjab.

In January, a tribunal named by the central government will decide conflicting claims between Punjab and Haryana to river waters that flow through Sikh farmlands.

Should the binding decisions of the government commissions go sharply against Sikh interests, the Akalis would find themselves under heavy pressure from militant Sikhs.

Perhaps the single most far-reaching issue contained in the July accord, the Sikh demands for broad new powers for the Punjab state government, has been indefinitely postponed for study by a one-man commission set up to consider the overall question of state versus central government powers.

The first challenge to face the Akali government probably will be its promise to free many of those arrested in the central government's campaign against the terrorists. Such a move would be highly controversial, even if the Akali government were to have the authority to release the detainees, which remains uncertain.