The doctrine of judicial precedent is based on stare decisis. That is the standing by of previous decisions. Once a point of law has been decided in a particular case, that law must be applied in all future cases containing the same material facts.
For example in the case of Donoghue v Stevenson AC 562, (Case summary). The House of Lords held that a manufacturer owed a duty of care to the ultimate consumer of the product. This set a binding precedent which was followed in Grant v Austalian Knitting Mills  AC 85 (Case summary). Also in Shaw v DPP  AC 220 (Case summary) the House of Lords held that a crime of conspiracy to corrupt public morals existed. This was followed in Knuller v DPP  AC 435 (Case summary).
In order for the doctrine of judicial precedent to work, it is necessary to be able to determine what a point of law is. In the course of delivering a judgment, the judge will set out their reasons for reaching a decision. The reasons which are necessary for them to reach their decision amount to the ratio decidendi of the case. The ratio decidendi forms the legal principle which is a binding precedent meaning it must be followed in future cases containing the same material facts. It is important to separate the ratio decidendi from the obiter dicta.
The obiter dicta is things stated in the course of a judgment which are not necessary for the decision. For example in R v Howe & Bannister  2 WLR 568 Case summary the House of Lords held that the defence of duress was not available to murder. This was the ratio decidendi of the case. The House of Lords went on to consider whether the defnce should be available to those who attempt murder and stated obiter dicta that the defence of duress should not be available to attempted murder.
In addition to binding precedents, there exists persuasive precedents. These consist of judicial statements which are not binding but may be taken into account. For example, the obiter dicta from R v Howe & Bannister was followed by the House of Lords in R v Gotts  2 AC 412 Case summary which held that the defence of duress was not available to attempted murder. A form of persuasive precedent is obiter dicta. Persuasive precedents also include case law from other jurisdictions and traditionally the Privy Council decisions have been merely persuasive on the English courts. However, exceptionally the Privy Council may be binding:
Attorney General for Jersey v Holley  3 WLR 29 Case summary
Hierarchy of the courts
There exists a hierarchy of the courts. The basic rule is that a court must follow the precedents from a higher court, but they are not bound to follow decisions from courts lower in the hierarchy. A basic outline of the hierarchy is:
European Court of Justice
Supreme Court (formerly House of Lords)
Court of Appeal
All other courts (County, Crown, Magistrates, tribunals – these have no power to create precedents)
Where the precedent was set by a court of the same level, the court is generally bound by the previous decision, but this is subject to exceptions. Different considerations apply depending on the level of court as to whether the court may depart from a previous decision of a court of the same level.