In a major political setback, Prime Minister Indira Gandhi's Congress (I) party suffered humiliating defeats in two traditional strongholds in south India.

It was the first time since India won independence in 1947 that the Congress (I) party, or its predecessor the Congress party, lost power in a southern state.

The balloting was nominally for state assembly seats in Andhra Pradesh and Karnataka, but stunning upsets of Congress candidates in both states suggested that Gandhi is losing her grip on a vast region of India which she has taken for granted. Should a chain reaction develop in other states before the national elections two years hence, it could jeopardize her firm control of Indian politics.

With nearly all of the paper ballots from yesterday's voting counted in the southwestern state of Karnataka, opposition candidates had won at least 139 of the 224 assembly seats, while Congress candidates took only 79 seats.

The dominant opposition Kranti Ranga-Janata alliance thus was in a position to form a coalition government with the other opposition parties. Janata is a national party while the Kranti Ranga is a regional one.

Gandhi's handpicked chief minister, or governor, in Karnataka, Gundu Rao, who boasted he could "win anywhere in the state," was defeated and resigned his post.

In the prime minister's home constituency of Andhra Pradesh, the 9-month-old Telegu Desam party was leading by a 4-to-1 margin, and the Congress candidate in Gandhi's own parliamentary district was voted out of office.

Telegu Desam won an absolute majority, with 165 of the 294 assembly seats, leaving only 42 seats to the Congress party and the remainder spread among other opposition parties.

The Congress (I) party--the I stands for Indira--had been voted to power in the state's six previous elections. In 1978, at the nadir of Gandhi's political career, the party won 175 of the 294 assembly seats, and in Karnataka, where the prime minister started her comeback trail in 1980, Congress swept the '78 assembly elections, as it did in the 1980 parliamentary elections.

The founder of the Telegu Desam party in Andhra Pradesh, Nandamuri T. Rama Rao, a portly, 60-year-old movie idol who appealed to strong regional feelings and pride in the dominant Telegu language, rolled over Congress candidates in two assembly districts in the state.

Rama Rao, who will almost certainly become chief minister of the state, attributed his sweeping victory to what he termed the "unpopularity, ineptness and corruption" of the Congress government in the state.

Gandhi's party also was defeated in the small, far northeastern state of Tripura, which has been controlled by a leftist alliance headed by the Communist Party of India (Marxist). A Congress alliance with a regional party lost by a 3-to-1 margin.

The vote-counting in the southern states appeared to signal an end to Gandhi's charismatic and almost matriarchal hold on the electorate, which has been the dominant feature of Indian politics.

Mindful of the stakes of the elections, the prime minister made an unprecedented campaign effort in Andhra Pradesh and Karnataka, crisscrossing the states by helicopter for 16 days with her son and heir-apparent, Rajiv, 38, six chief ministers and 25 ministerial-level officials from the central government in New Delhi.

Northern Indian states traditionally have dominated national politics here, and Congress Party strategists had become convinced that there could be no startling shifts in the south. Nevertheless, the party's image has deteriorated there in the last two years, partly because of growing restiveness over corruption scandals and administrative ineptness, but also because of the heavy-handed control of state politics by the central leadership in New Delhi.

As elsewhere in the country, the Congress Party in Andhra Pradesh and Karnataka has been torn by dissension and rivalries between longtime party loyalists and recent converts to Gandhi's fold who have been rewarded with generous patronage. As a result, Gandhi's image has suffered because she has been perceived by many erstwhile supporters as having reduced the party organization to a narrow personality cult.

But in Andhra Pradesh, it was the strong personal following of Rama Rao, popularly known as "NTR," that appeared to thrust the Telegu Desam party into power in its first election.

Rama Rao, who has portrayed deities in hundreds of Indian classical films, appeared to have matched Gandhi's own formidable force of personality and charisma, attracting huge crowds wherever he campaigned.

His campaign focused on Telegu honor and a strong appeal to regionalism, as well as alleged corruption and neglect of south India by the central government.

Wednesday's voting was marked by violence which caused six deaths.