To pull someone's leg is to tease or joke with them — to make them believe something false in a playful, good-natured way. 'Are you pulling my leg?' means 'Are you serious, or are you making this up?' The deception is understood to be light-hearted rather than malicious.
The most widely cited origin involves Victorian-era street criminals in Britain who would trip or pull at the legs of pedestrians to knock them down, making them easier to rob. The 'leg-pull' was a street crime tactic. From this physically literal act, the phrase evolved metaphorically: to pull someone's leg became to knock their sense of reality off balance — to trip them up with a false story. The transition from literal crime to playful deception is a natural semantic shift.
The phrase appears in print from the early 1880s in Scottish newspapers, suggesting a British origin. By the 1890s it was in common use across Britain and had crossed to America. Early uses often imply deceit rather than simple fun, and the tone shifted gradually from mildly sinister to entirely playful as the century turned.
No — a lie is intended to deceive for gain or to avoid consequences. Pulling someone's leg is playful, with the expectation that the joke will be revealed and shared in good humour. The difference is intent.
Spanish has 'tomar el pelo' (to take someone's hair), French has 'faire marcher quelqu'un' (to make someone walk), and German has 'jemanden auf den Arm nehmen' (to take someone on the arm). All describe the same act of good-natured deception.