Indian Prime Minister Rajiv Gandhi announced today that he has reached a negotiated settlement to the bitter conflict in the strategically important northeastern state of Assam, where thousands of persons have been killed in the past six years.

As did his agreement last month with Sikh dissidents from Punjab State, Gandhi's accord with Assamese militants has quieted a long and bloody civil conflict, which many Indians once thought intractable. Gandhi, who largely initiated both peace processes, stands to improve his already strong political position as a result.

Gandhi, who has just returned from Assam, announced the settlement during an Independence Day speech from the ramparts of Old Delhi's Red Fort, once the seat of Mogul emperors who ruled much of India. After unfurling the Indian tricolor and receiving a 21-gun salute, Gandhi spoke solemnly in Hindi to a crowd of Indian and foreign dignitaries.

"We hope that with . . . this agreement, another area of tension will be removed from Indian life," he said. When he took office, Gandhi said, "The biggest challenge confronting us was to maintain the unity and integrity of India. Ten months ago, the world was watching whether India would disintegrate into pieces. Today, that question does not arise."

The "Assam agitation," as the conflict is generally called here, began in 1979 when mainly Hindu Assamese began fighting for the deportation of ethnic Bengali immigrants, mostly Moslem, who had poured into the state from more densely populated areas of Bangladesh and India. Assamese extremists, including many students, often used violence in their campaign, and at least 3,000 persons were killed in widespread fighting and massacres in Assam during elections in 1983.

The two sides signed the accord at 2:45 a.m. today at Gandhi's residence, after nearly 20 hours of continuous meetings. The final negotiations were apparently slowed as both the agitation leaders and Gandhi's ruling Congress (I) Party maneuvered for future political advantage in Assam.

The government said it would announce details of the agreement Friday in Parliament. Reports in the Indian press conflicted on some points but generally agreed that immigrants who arrived in Assam before 1966 would be permitted to retain full citizens' rights there.

According to Assamese dissident leaders cited by the United News of India news agency, immigrants who arrived in Assam between 1966 and 1971 will be disenfranchised for a 10-year period, while later arrivals face deportation. Press reports said the Congress (I) government had wanted to maintain the voting rights of some post-1966 arrivals, most of whom are thought to be sympathetic to the party.

The agreement also stipulates that the Congress (I) state government in Assam will resign and be replaced by a caretaker government until new elections can be held, the news agency reported. The central government also promised new industrial investment in the state, where economic backwardness has intensified social and ethnic tensions.

Gandhi's announcement drew widespread approval from the Congress (I) and opposition parties.