Median nerve
The median nerve is a nerve in humans and other animals in the upper limb. It is one of the five main nerves originating from the brachial plexus.
The median nerve originates from the lateral and medial cords of the brachial plexus, and has contributions from ventral roots of C5-C7 (lateral cord) and C8 and T1 (medial cord).The median nerve is the only nerve that passes through the carpal tunnel. Carpal tunnel syndrome is the disability that results from the median nerve being pressed in the carpal tunnel.

Structure
The median nerve arises from the branches from lateral and medial cords of the brachial plexus, courses through the anterior part of arm, forearm, and hand, and terminates by supplying the muscles of the hand.

Arm
After receiving inputs from both the lateral and medial cords of the brachial plexus, the median nerve enters the arm from the axilla at the inferior margin of the teres major muscle. It then passes vertically down and courses lateral to the brachial artery between biceps brachii (above) and brachialis (below). At first, it is lateral to the artery and lies anterior to the shoulder joint; it then crosses anteriorly to run medial to the artery in the distal arm and into the cubital fossa. Inside the cubital fossa, the median nerve passes medial to the brachial artery. The median nerve gives off an articular branch to the elbow joint. A branch to pronator teres muscle arise from the median nerve immediately above the elbow joint.

Forearm
The median nerve continues in the cubital fossa medial to the brachial artery and passes between the two heads of  the pronator teres, deep to the bicipital aponeurosis (aponeurosis of biceps) and superficial the brachialis muscle. It crosses the ulnar artery (branch of brachial artery) while being separated by the deep head of the pronator teres. It then travels between the flexor digitorum superficialis (above) and flexor digitorum profundus (below). The median nerve is accompanied by the median artery (a branch of anterior interosseous artery) during this course. Then,  about 5 cm above the flexor retinaculum (wrist), it emerges between the flexor digitorum superficialis (medially) and the flexor carpi radialis (laterally) into the hand.The main trunk of the median nerve innervates the superficial and deep groups of the muscles in the anterior compartment of the forearm with the exception of flexor carpi ulnaris. The median nerve does this by giving off two branches as it courses through the forearm:

Muscular branches are given off in the cubital fossa to supply flexor carpi radialis, palmaris longus, and flexor digitorum superficialis.
The anterior interosseous branch is given off in the upper part of the forearm, courses with the anterior interosseous artery and innervates flexor pollicis longus and the lateral half of flexor digitorum profundus (the ulnar half is supplied by ulnar nerve, as is the flexor carpi ulnaris muscle). It ends with its innervation of pronator quadratus. In addition to its supply to muscles, this nerve also supplies the distal radioulnar joint and wrist joint.The median nerve also gives off sensory and other branches in the forearm. The palmar cutaneous branch of the median nerve arises at the distal part of the forearm. It supplies sensory innervation to the thenar eminence of the palm and the central palm. Articular branches are given to the elbow joint and proximal radioulnar joint. Vascular branches supply the radial and ulnar arteries. Meanwhile, a communicating branch is given to the ulnar nerve.

Hand
The median nerve enters the hand through the carpal tunnel, deep to the flexor retinaculum along with the tendons of flexor digitorum superficialis, flexor digitorum profundus, and flexor pollicis longus. From there, it is divided into recurrent muscular branch and digital cutaneous branch:
The muscular branch (also known as recurrent branch) supplies the thenar muscles (opponens pollicis, abductor pollicis brevis, and superficial part of flexor pollicis brevis)
Digital cutaneous to the proper palmar digital branch and the common palmar digital branch: The proper palmar digital branch gives out three digital branches to the lateral one and a half digits (two digital branches to the thumb, one digital branch to the lateral side of the index finger). The digital branch to the index finger also supplies the first lumbrical. The common palmar digital branch divides further into two branches. Both the medial and lateral branches supply the second and third interdigital clefts with adjoining index, middle, and lateral half of ring finger. The lateral branch also supplies the second lumbrical.

Variation
The naturally occurring anomalies of the median nerve are:

Bifurcation of the median nerve typically occurs after the nerve exits the carpal tunnel; however, in a small percentage (5-10%) of individuals, the median nerve bifurcates more proximal in the carpal tunnel, wrist, or forearm.
During gestation, a median artery that serves the hand retracts.  However, in some individuals, the median artery does not retract and follows the course next to the median nerve into the hand.
Martin-Gruber anastomoses can occur when branches of the median nerve cross-over in the forearm and merge with the ulnar nerve to innervate portions of the forehand.
Riche-Cannieu anastomosis can occur when a connection exists between recurrent branch of the median nerve and deep branch of the ulnar nerve of the hand.

Function
The median nerve is the main nerve of the front of the forearm. It supplies the muscles of the front of the forearm and muscles of the thenar eminence, thus controlling the coarse movements of the hand. Therefore, it is also called "labourers nerve".

Arm
The median nerve has no voluntary motor or cutaneous function in the brachium. It gives vascular branches to the wall of the brachial artery. These vascular branches carry sympathetic fibers.

Forearm
It innervates all of the flexors in the forearm, except flexor carpi ulnaris and that part of flexor digitorum profundus that supplies the fourth and fifth digits. The latter two muscles are supplied by the ulnar nerve (specifically the muscular branches of ulnar nerve).
The main portion of the median nerve supplies these muscles:
Superficial group:

Pronator teres
Flexor carpi radialis
Palmaris longusIntermediate group:

Flexor digitorum superficialis muscleThe anterior interosseus branch of the median nerve supplies these muscles:
Deep group:

Flexor digitorum profundus (only the lateral half)
Flexor pollicis longus
Pronator quadratus

Hand
In the hand, the median nerve supplies motor innervation to the first and second lumbrical muscles. It also supplies the muscles of the thenar eminence by a recurrent thenar branch. The rest of the intrinsic muscles of the hand are supplied by the ulnar nerve.
The median nerve innervates the skin of the palmar (volar) side of the index finger, thumb, middle finger, and half the ring finger, and the nail bed. The radial aspect of the palm is supplied by the palmar cutaneous branch of the median nerve, which leaves the nerve proximal to the wrist creases. This palmar cutaneous branch travels in a separate fascial groove adjacent to the flexor carpi radialis and then superficial to the flexor retinaculum. It is, therefore, spared in carpal tunnel syndrome.

Clinical significance
Injury
Injury of median nerve at different levels causes different syndromes with varying motor and sensory deficits.

At the shoulder
Injury can occur at the brachial plexusAbove the elbow

Common mechanism of injury: A supracondylar humerus fracture
Motor deficit:
Loss of pronation of forearm, weakness in flexion of the hand at the wrist, loss of flexion of radial half of digits and thumb, loss of abduction and opposition of thumb.
Presence of an ape hand deformity when the hand is at rest, due to an hyperextension of index finger and thumb, and an adducted thumb
Presence of benediction sign when attempting to form a fist, due to loss of flexion of radial half of digits
Sensory deficit: Loss of sensation in lateral 3+1⁄2 digits including their nail beds, and the thenar areaAt the elbow

Entrapment at the level of the elbow or the proximal forearm could be due to the pronator teres syndrome.Within the proximal forearm: Anterior interosseous syndrome

Injury to the anterior interosseous branch in the forearm causes the anterior interosseous syndrome
Common mechanisms: Tight cast, forearm bone fracture
Motor deficit: Loss of pronation of forearm, loss of flexion of radial half of digits and thumb
Sensory deficit: NoneAt the wrist

Common mechanism: Wrist laceration
Motor deficit:
Weakness in flexion of radial half of digits and thumb, loss of abduction and opposition of thumb
Presence of an ape hand deformity when the hand is at rest may be likely, due to an hyperextension of index finger and thumb, and an adducted thumb. Nevertheless, an ape hand deformity is not a requirement for a carpal tunnel syndrome diagnosis.
Presence of a benediction sign when attempting to form a fist, due to weakness in flexion of radial half of digits
Sensory deficit: Loss of sensation in lateral 3+1⁄2 digits including their nail beds, and the thenar areaWithin the wrist: Carpal tunnel syndrome

Common mechanism: Carpal tunnel syndrome, an injury by compression in the carpal tunnel, without transection of the median nerve, due to overuse by activities such as keyboard typing and cooking
Motor deficit:
Weakness in flexion of radial half of digits and thumb, weakness in abduction and opposition of thumb
Presence of an ape hand deformity or when attempting to form a fist, the benediction sign, due to compression of the median nerve, as opposed to complete median nerve palsy
Sensory deficit: Numbness and tingling in lateral 3+1⁄2 digits including their nail beds, but excluding the thenar eminence which is supplied by the palmar cutaneous branch of the median nerve Unlike in wrist laceration,  sensation still occurs in the area of the central palm. Sensation is not lost because the palmar cutaneous branch runs above the flexor retinaculum, and is not affected in compression in carpal tunnel syndrome.

Additional images
See also
References
This article incorporates text in the public domain from page 938 of the 20th edition of Grays Anatomy (1918)

External links

Median nerve at the Duke University Health Systems Orthopedics program
Median+Nerve at the US National Library of Medicine Medical Subject Headings (MeSH)
Hand kinesiology at the University of Kansas Medical Center
Atlas image: hand_plexus at the University of Michigan Health System - "Axilla, dissection, anterior view"