MUMBAI—India's central bank Friday surprised markets by raising its key lending rate for the first time in two years, demonstrating its commitment to fighting inflation even as the country struggles with a slowdown and a world-wide selloff in emerging-market assets.

The Reserve Bank of India increased the rate at which it lends to banks overnight by a quarter percentage point to 7.5%. The central bank hasn't raised that rate, called...