Bajpai was first elected to Parliament in 1957 as a member of the Bharatiya Jana Sangh (BJS), a forerunner of the BJP. In 1977 the BJS joined three other parties to form the Janata Party, which led a government that lasted until July 1979. As foreign minister in the Janata government, Bajpai earned a reputation for improving relations with Pakistan and China. In 1980, following a split in the Janata Party, Bajpai helped the BJS to reorganize itself as the BJP. In 1992 he was one of the few Hindu leaders to speak out against the destruction of the historic mosque at Ayodhya by anti-Muslim extremists.