The lateral pterygoid muscle (in purple above) is responsible for moving the lower jaw from side to side when the right or left lateral pterygoid is active separately. Contraction of the right lateral pterygoid muscle moves the jaw to the left, and contraction of the left draws the jaw to the right. It is also responsible, in combination with the digastric muscle for opening the lower jaw during the translation phase of opening. It is shaped a bit like a partly unfolded fan.
The wide end of the fan, it's origin, originates from a small, finlike projection under the skull called the lateral pterygoid plate. The narrow end of the fan inserts into the anterior surface of the coronoid process.
Notice that the lateral pterygoid has two bellies. The light colored object projecting downward between the two bellies is the mandibular nerve on its way toward the mandibular foramen. The upper belly of the lateral pterygoid is attached primarily to the articular disk while the lower belly is attached to the neck of the condyle. The two bellies may work independently, but usually in concert to keep the articular disk always situated between the closest points of contact between the condyle and the glenoid fossa during both the rotational phase of jaw opening and the translational phase. In pathologic conditions, the two bellies can contract at different rates which causes the articular disk to be pulled ahead of the condyle during transulatory movements. This can tear the cartilage damaging the joint and allowing the condyle to snap up against the glenoid fossa. This is what causes the clicking that TMJ patients notice when opening or closing their mouths.
The medial pterygoid muscle (in red) arises from the medial (inside) surfaces of the lateral pterygoid plate which is attached to the undersurface of the temporal bone. In lay terms, the attachment is on the undersurface of the skull just behind the last upper tooth. The fibers of the medial pterygoid are directed downward and backward, just like the masseter (pictured above), only on the inside of the mandible. The insertion of this muscle is to the inside of the lower border and angle of the mandible. The masseter and medial pterygoid act like a contractile "hammock" in which the lower jaw rests. These two muscles are more or less "twins", the masseter acting on the outside of the lower jaw and the medial pterygoid on the inside.