ISLAMABAD, Pakistan — A former Pakistani Supreme Court chief justice has been chosen as the caretaker prime minister until late July, when Pakistan is to hold general elections.

The appointment of the former justice, Nasir ul-Mulk, as the head of a neutral, interim government was announced at a joint new conference in Islamabad on Monday by Prime Minister Shahid Khaqan Abbasi and Syed Khurshid Shah, the opposition leader.

Mr. Mulk is likely to be sworn in on Friday.

The election marks the second democratic transition in Pakistan’s history, though it comes amid months of political tumult and civil-military tensions.

“With the selection of the former chief justice as caretaker prime minister, Pakistan’s democracy is showing signs of a pulse, albeit a faint one,” said Arif Rafiq, a political analyst and a nonresident fellow at the Middle East Institute. “The major political parties are continuing a recent tradition of selecting by consensus an impartial figure to oversee the election process, thereby increasing the odds that it will be free, fair and credible.”