Not quite sure, but thinking further, I think that the sitting PM has first go at it. In case of majority, of course it's moot.
wikipedia;
When all the results are known, or when one party achieves an absolute majority of the seats in the House of Commons, the first response comes from the current (and possibly outgoing)
Prime Minister. If a majority in the new Parliament has been achieved by their party, they remain in office without the need for reconfirmation or reappointment—no new "term" of office is started. If a majority has not been achieved, and it is obvious that another party has the numbers to form a government, the Prime Minister submits his/her resignation to the Monarch. The Monarch then commissions the leader of the new majority party to form a new government. The Prime Minister can try to remain in power even without a majority. The subsequent
"Queen's Speech" (giving an outline of the government's proposed legislative programme) offers a chance for the
House of Commons to cast a
vote of confidence or no confidence in the government by accepting or rejecting the Queen's Speech.