The scene could be straight out of a Wild West movie.

Masked desperados with bandoleers slung across their chests lurk around hairpin railroad bends, waiting for accomplices aboard the night mail train to yank an emergency cord and bring it to a screeching stop.

The bandits clamber aboard, robbing terrified passengers as they race from compartment to compartment, sometimes gunning down a protester. Then, as quickly as they came, they disappear into the darkness, leaving behind another legend of the dreaded dacoits who have institutionalized Indian outlawry.

Train robberies, which are fading into history in most of the world, are on an increase in India and caused a minor furor in Parliament last week after two deputies were robbed on the Tinsukia mail express.

Railway Minister A.B.A. Ghani Khan Choudhury startled the Parliament by admitting that banditry, looting and "gangsterism" aboard trains has become a serious social problem in India and is causing concern among many government officials, including Prime Minister Indira Gandhi.

Choudhury said he was determined to make train travel in India less harrowing and he intended to press for amendments to existing rules that limit the police powers of the Railway Protection Force, which escorts some trains here.

But he complained that policing of the railways is the responsibility of state governments and that his force's hands are tied.

Mahesh D. Diksit, inspector-general of the 66,000-man Railway Protection Force, acknowledged in an interview that dacoities or bandit raids were increasing on the rail lines, but he complained that the danger had been blown out of proportion because of a few sensational robberies.

Last year, there were 370 bandit raids on trains in India, Diksit said, compared to 351 in 1980 and 253 the year before. He said he expected the year's total to reach 400.

But considering that India's railroads cover 39,600 miles of track and carry 10 million passengers a day, Diksit said, the number of train robberies is small.

"It doesn't happen every day. If it did, there wouldn't be such a hue and cry in the Parliament. It is only because it is so unusual that it attracts attention," Diksit said in a seemingly ingenuous explanation of the phenomenon.

He added, "These crimes cause a scare that bears no relation to the danger. We are doing our best to deal with the problem."

Diksit said a direct relation exists between the rate of train robberies and the crime rate of the territories through which the trains pass. For example, the state of Uttar Pradesh in northern India -- traditionally a crime-ridden area -- had 87 train robberies last year, more than any other state. Other dangerous states, Diksit said, are West Bengal and Bihar.

Diksit said only a third of his force is armed and while his men escort freight trains carrying valuable goods or open cars, they do not normally accompany passenger trains.

The bandits, who usually hide in caves in twisting ravines in rural India, occasionally use mines or other explosive devices to derail trains they intend to loot.

Last year, Railway Protection Force authorities said, 36 passengers were murdered on running trains and 160 seriously injured in dacoit raids and robberies. Of the robberies, less than half have been solved.

In addition to the bandit attacks, railway officials have had their hands full with thefts of cargo and railroad equipment. While valuable cargo -- particularly arms and ammunition -- are favored by railroad thieves, railroad switches and brake blocks are also popular items. Last year, more than 4,300 cases of theft of 40-pound iron brake blocks--usually sold on the scrap market -- were reported.

In the Nawadah area of Bihar state in eastern India, hundreds of hungry villagers earlier this month stopped a freight train and looted wheat worth $100,000 before police drove them away.

Diksit said his Railway Protection Force, spread thinly across the huge rail system, is dealing with train robberies as best it can. But he said there has to be a balance between the scope of the problem and how much society is prepared to spend to correct it.

"The tales of horror naturally cause a feeling of insecurity, and passengers want to feel safe. But our powers are limited," the inspector-general said.