Four people were killed and nearly 50 were injured in riots here today after a newspaper published an article that offended Moslems.

Police Commissioner P. G. Halarankar told reporters that the killings occurred when his officers fired on a mob trying to burn down the newspaper office.

Many of the injuries occurred later, as disturbances broke out in several areas.

The entire police force was mobilized, state reserves were called in, and a ban was imposed on gatherings or carrying arms for five days. The police said the rioting continued tonight.

About 5,000 Moslems tried to burn office of the paper, The Deccan Herald, after the paper had printed a short story in its Sunday magazine titled ''Mohammad the Idiot.'' The story concerned a handicapped youth named Mohammad, but the Moslems, who make up 10 percent of the city's population, asserted that a reference to him as ''a deaf and dumb prophet'' was an insult to their religion.