The Prime Minister of the United Kingdom is:
the person most likely to command the confidence of the House of Commons
In practise, that does indeed tend to be the leader of the party with the most seats -- but it doesn't have to be.
For example, if the parties with the second and third largest number of seats decide to form a coalition, and the coalition then has a majority in the Commons, then the prime minister would likely be the leader of one of those parties.
If there were no political parties, the above requirement remains the same - but it becomes less obvious who that person should be. Ultimately, the Queen appoints the Prime Minister, and so she would have to pick someone who her advisers felt could survive a vote of confidence.