A line segment has two endpoints and a finite length, while a ray has only one endpoint and extends infinitely in one direction.