The Prime Minister is the head of state and/or government, as is David Cameron in the UK.
As head of government, the PM can operate a change of directions with former policy, as did Cameron and Blair with the UK-EU relationship.
In most systems, the PM presides and chairs the cabinet, and in semi-presidential systems, he/she is the official who executes the directives of the head of state and manages civil service.
The history and special role of the Prime Minister dates far back. Monarchs of England and the UK had special ministers in which they placed special trust, such as Oliver Cromwell, but their powers depended entirely on the monarch himself. Cromwell, for instance, was thus executed by the monarch. From the mid-17th century, Parliament strengthened its powers with the Bill of Rights in 1689, making House of Commons a central actor in the passing of laws and imposition of taxes. It is under George I that the function gained more power. From 1721, politician Robert Walpole acted as PM for 21 years: he was able to lead the Commons and make sure they would vote in accordance with his positions.
Thus, although the term was not formally referred to until 1905 in the British Order of precedence, the function was created and developed much earlier. Depending on countries, the constitution can make note, or not, of the function of Prime Minister. The UK, whose constitution is uncodified and largely unwritten, makes no mention of the function.
Most Prime Ministers are not appointed for a specific term and may remain in office through executive and parliamentary elections. For instance, Margaret Thatcher was only appointed PM once, in 1979, but remained in power until 1990. In other systems, they must be reappointed after every election.