Touchdowns are usually scored by the offense. However, the defense can also score a touchdown if they have recovered a fumble or an interception and return it to the opposing end zone. Special teams can score a touchdown on a kickoff or punt return, or on a return after a missed field goal attempt. In the NFL, a touchdown may be awarded by the referee as a penalty for a "Palpably Unfair Act".
When the touchdown was introduced into American football in 1876, it did not award a score; instead, it only allowed the offense the chance to kick for goal by placekick from a spot along a line perpendicular to the goal line and passing through the point where the ball was touched down, or through a process known as a "punt-out", where the attacking team would kick the ball from the point where it was touched down to a teammate. If the teammate could fair catch the ball, he could follow with a try for goal from the spot of the catch, or resume play as normal (in an attempt to touchdown the ball in a spot more advantageous for kicking).
In 1881, the rules were modified so that a goal kicked from a touchdown took precedence over a goal kicked from the field in breaking ties.
In 1882, four touchdowns were determined to take precedence over a goal kicked from the field. Two safeties were equivalent to a touchdown.
In 1883, points were introduced to football, and a touchdown counted as 4 points. A goal after a touchdown also counted as 4 points.
In 1889, the provision requiring the ball to actually be touched to the ground was removed. A touchdown was now scored by possessing the ball beyond the goal line.
In 1897, the touchdown scored 5 points, and the goal after touchdown added an additional point.
In 1900, the definition of touchdown was changed to include situations where the ball becomes dead on or above the goal line.
In 1912, the value of a touchdown was increased to 6 points. The end zone was also added. Before the addition of the end zone, forward passes caught beyond the goal line resulted in a loss of possession and a touchback. (The increase from 5 points to 6 did not come until much later in Canada, and the touchdown remained only 5 points there until 1956.)
The ability to score a touchdown on the point-after attempt (two-point conversion) was added to NCAA football in 1958, high school football in 1969, and the NFL in 1994.