LONDON — What was expected to be a routine cabinet reshuffle by Prime Minister Boris Johnson took an extraordinary turn on Thursday, when the Treasury chief, Sajid Javid, abruptly resigned rather than cede some of his power over economic policy to Mr. Johnson.

The surprise departure of such a senior figure was a significant blow to Mr. Johnson; the Treasury is traditionally the most powerful department in the British government, and the chancellor of the Exchequer, who leads it, is usually the second-most important politician after the prime minister.

Rishi Sunak, 39, who as chief secretary to the Treasury had been Mr. Javid’s deputy, was named to succeed him as chancellor — a remarkable rise for a former employee of Goldman Sachs who was elected to Parliament only in 2015.

The drama unfolded on a difficult day for Mr. Johnson, as the opposition Labour Party demanded clarity about who had paid for a luxury Caribbean vacation taken by the prime minister and his partner in late December and early January.