The ulnar nerve is a terminal branch of the brachial plexus that provides motor innervation to muscles in the forearm, hand, and fingers. It passes through the cubital tunnel in the elbow and Guyon's canal in the wrist. In the forearm, it gives off motor branches and sensory branches. In the hand, the ulnar nerve divides into superficial and deep branches, with the superficial branch supplying sensation to the little and half of the ring finger and motor innervation to the thenar muscles, and the deep branch supplying motor innervation to the majority of hand muscles.