In Major League Baseball, a loss (denoted L) is charged to the pitcher of the losing team who allows the run that gives the opposing team the lead which the game is won with (the go-ahead run). If a pitcher allows a run which gives the opposing team the lead but this lead is not held for the remainder of the game, that pitcher does not get the loss. To be the pitcher to have allowed a game's go-ahead run, a pitcher is responsible for the plate appearance which puts the runner on base who scores the run, which is not necessarily the pitcher who is responsible for the plate appearance which causes this runner to score.
For example, in a tie ball game, if pitcher A walks a batter and then is relieved by pitcher B who then gives up a home run, the first run allowed is recorded to pitcher A and the second to pitcher B. Thus, pitcher A gave up the run that gave the opposing team the lead, and pitcher A will be credited with the loss if the other team does not relinquish the lead, even though pitcher B was on the mound when the go-ahead hit occurred.