Perhaps the most famous example in the US is the combination of Minneapolis, Minnesota and Saint Paul, Minnesota (although the metropolitan area of the Twin Cities actually includes seven counties and dozens of cities, Minneapolis and Saint Paul form the urban, cultural and economic core of the area).
Twin cities are often separated by a river - cities without this physical barrier more often become a single entity, as with the growth of London from the what is now called the City of London into its surroundings to encompass the City of Westminster and other towns. Budapest also formed in this manner.
Some twin cities form on opposite sides of natural or governmental boundaries as conduits for trade between the two sides. For instance, Albury and Wodonga in south-eastern Australia are on the state border between New South Wales and Victoria), and formed as customs posts when the two states were independent colonies. The border between the United States and Mexico is significant in this respect because there is a chain of twin cities, particularly around the Rio Grande valley. Others began as distinct cities, but growth caused them to merge into each other and assume a single identity; an example of this is Budapest.
Note that not all geographically close cities are combined in this way. In the United Kingdom, for example, the cities of Leeds and Bradford are very close, but have strong separate identities and would not see themselves as part of the same entity.
Examples of twin cities:
Contrast Twin Cities to the term twin towns, a pairing of geographically separate towns (usually international).
Compare with the term Quad Cities, which refers to a similar group of four towns. Perhaps the most famous of these are the towns of Davenport, Iowa - Bettendorf, Iowa - Rock Island, Illinois - Moline, Illinois, all in the United States. East Moline, Illinois was later added to the group, and the Quad Cities term now refers to all five collectively. Of these, the Iowa and Illinois towns are separated by the Mississippi River.
One unusual case -- Lloydminster, Alberta/Saskatchewan in Canada -- may be considered a "twin city", but is in fact incorporated as a single city straddling a provincial border and administered jointly by both provinces.