LONDON — In the first electoral test for Britain’s new prime minister, the Conservatives lost a special election on Thursday, cutting Boris Johnson’s already slim working majority in Parliament to just one.

During his first week in power, Mr. Johnson has sought to project the image of an energetic leader who is determined to take Britain out of the European Union by an Oct. 31 deadline and who is willing to risk a disorderly withdrawal without an agreement if necessary.

But Thursday’s election loss, in the Brecon and Radnorshire region of Wales, is a reminder of the fragility of his position in Parliament. A majority of lawmakers in London have previously voted against a “no deal” Brexit, and further moves are underway in the legislature to try to block such an outcome.

The possibility of leaving the European Union on Oct. 31 without a deal has also put pressure on the British pound. On Thursday, the currency fell below $1.21, a level not seen in two and a half years.