Pajamas or pyjamas, often shortened to PJs, jimmies, jimjams or jammies, can refer to several related types of clothing. Pajamas are loose-fitting garments derived from the original garment and worn chiefly for sleeping, but sometimes also for lounging, also by both sexes. More generally, pajamas may refer to several garments, for both daywear and nightwear, derived from traditional pajamas and involving variations of style and material.
The word pyjama was borrowed c. 1800 from Urdu pāy-jāma پايجامه , itself borrowed from Persian pāy-jāmeh پايجامه lit. 'leg-garment'. The original pyjāmā are loose, lightweight trousers fitted with drawstring waistbands worn by Muslims in India and adopted by Europeans during East India Company rule in India.
The worldwide use of pajamas (the word and the garment) is the result of adoption by British colonists in India in the 18th and 19th centuries, and the British influence on the wider Western world during the Victorian era. Pajamas had been introduced to England as "lounging attire" as early as the seventeenth century, then known as mogul's breeches (Beaumont and Fletcher) but they soon fell out of fashion. The word pajama (as pai jamahs, Paee-jams and variants) is recorded in English use in the first half of the nineteenth century. They did not become a fashion in Britain and the Western world as sleeping attire for men until the Victorian period, from about 1870.
Hobson-Jobson: A Glossary of Colloquial Anglo-Indian Words and Phrases (1886) summarizes the state of usage at the time (s.v. "pyjammas"):
Such a garment is used by various persons in India e.g. by women of various classes, by Sikh men, and most by Mohammedans of both sexes. It was adopted from the Mohammedans by Europeans as an article of dishabille and of night attire, and is synonymous with Long Drawers, Shulwaurs, and Mogul-Breeches [...] It is probable that we English took the habit like a good many others from the Portuguese. Thus Pyrard (c. 1610) says, in speaking of Goa Hospital: "Ils ont force calsons sans quoy ne couchent iamais les Portugais des Indes" [...] The word is now used in London shops. A friend furnishes the following reminiscence: "The late Mr. B—, tailor in Jermyn Street, some on 40 years ago, in reply to a question why pyjammas had feet sewn on to them (as was sometimes the case with those furnished by London outfitters) answered: "I believe, Sir, it is because of the White Ants."