mid-15c., transitive, "to choke, strangle" (someone), possibly imitative and perhaps influenced by Old Norse gag-hals "with head thrown back." The sense of "stop a person's mouth by thrusting something into it" is first attested c. 1500. Intransitive sense of "to retch" is from 1707. Transitive meaning "cause to heave with nausea" is from 1945. Related: Gagged; gagging.
"something thrust into the mouth or throat to prevent speaking," 1550s, from gag (v.); figurative use, "violent or authoritative repression of speech," is from 1620s. Gag-law in reference to curbs on freedom of the press is from 1798, American English. The gag-rule that blocked anti-slavery petitions in the U.S. House of Representatives was in force from 1836 to 1844.
"a joke," 1863, especially a practical joke, probably related to theatrical sense of "matter interpolated in a written piece by the actor" (1847); or from the sense "made-up story" (1805); or from slang verbal sense of "to deceive, take in with talk" (1777), all of which perhaps are from gag (v.) on the notion of "to stuff, fill." Gagster "comedian" is by 1932.