The UK system is very different from the US presidential system. Here we do not directly vote for a Prime Minister in the same way that the US votes for a President.
The convention is that the leader of the Parliamentary party with an outright majority is invited to form a government by the monarch although this is not always straightforward. Indeed as in the 2010 election failing to secure a majority does not, in of itself, remove the incumbent Prime Minister.
It is also entirely possible for a majority party to elect or appoint a new leader during a Parliament, this happened with Gordon Brown and there are no constitutional or legal bars to how a party leader is elected and different parties have their own individual systems.
It is even possible, in some circumstances for the Prime Minister to come from a minority party and the last government was composed of a coalition of two different parties. In the UK coalitions are rare but in some European countries they are the norm.
It is also worth noting that, in theory, the Prime Minister is appointed by the Monarch and indeed David Cameron will ultimately formally present his resignation to the Queen not Parliament.
Also unlike the situation in the US there is a substantial overlap between the elected legislature and the executive (the cabinet) composed of ministers, secretaries etc.
The Prime minister must, by convention, be a member of parliament, although historically several modern-ish Prime Ministers have been Peers and Peers can still have cabinet posts.
Also the formal posts within the government are in the gift of the Prime Minister and so posts and ministries have shifted somewhat over time, for example the recent separation between the Justice Ministry and Home Office.
There are also various miscellaneous but important posts such as Attorney General and Speaker of the House of Commons which aren't formally part of the government but have an important constitutional role .
That's without considering the House of Lords which has no analogy in US politics.