Britain has a parliamentary system, so unlike in the United States, people in Britain do not directly elect their national leader. They elect members of Parliament to represent them, and then the party, or coalition of parties, that holds the majority of seats in Parliament take government. Their leader then becomes prime minister.
So when a prime minister resigns, he or she must be replaced. And that's a decision made among the party MPs and party members. Members of Cameron's Conservative Party are seeking the prime ministership. They need the backing of at least two MPs to officially run. When there are three or more candidates, MPs vote in an initial round, and keep holding rounds until the number is whittled down to two. A final vote goes out to the wider party, and the winner is Britain's new prime minister.