The theory of money typically ignores the fact that the mode of market interaction arises endogenously, and simply assumes a decentralized, bilateral exchange process. However, endogenizing the organization of trade is critical for understanding the conditions that lend themselves to the development of money as a mode of exchange. To study this, we develop a "travelling game" to study the spontaneous emergence of different systems of exchange theoretically and experimentally. Players located on separate "islands" can either stay and trade on their island, or pay a cost to trade elsewhere. Earnings rise with the frequency of trade but fall with the frequency of travel. Decentralized and centralized markets can both emerge in equilibrium. The latter maximize consumption frequencies and are socially efficient; the former minimize travel cost and require the use of a medium of exchange. In the laboratory, a centralized market more frequently emerges when subjects perform diversified economic tasks, and when they interact in large groups and cannot be sure whether they will meet the same counterpart in later periods. The experiment shows that to understand the emergence of monetary systems it is important to amend the theory of money such that the market structure is endogenized.