The Pit and the Pendulum takes place in the Spanish city of Toledo, which is located in central Spain, not too far south of Madrid.
Poe's story is fictitious, but the Spanish Inquisition certainly had a presence in Toledo during its time. In the story, the narrator mentions the autos-da-fe, which was a public form of punishment for heretics or people who renounced the Catholic church (it usually meant being burned at the stake). The first autos-da-fe in the Spanish Inquisition was in Seville, but some did take place in Toledo, as there was a tribunal that had been permanently formed there in 1485. In fact, Toledo had the most autos-da-fe out of all the cities in Spain at one point.
The fictitious nature of Poe's story is further proved by the character General Lasalle, who was a real French general, but had nothing to do with ending the Spanish Inquisition in Toledo.