Tilting at windmills
Attacking imaginary enemies.
Tilting is jousting. 'Tilting at windmills' derives from Cervantes' Don Quixote - first published in 1604, under the title The Ingenious Knight of La Mancha. The novel recounts the exploits of would-be knight 'Don Quixote' and his loyal servant Sancho Panza who propose to fight injustice through chivalry. It is considered one of the major literary masterpieces and remains a best seller in numerous translations. In the book, which also gives us the adjective quixotic (striving for visionary ideals), the eponymous hero imagines himself to be fighting giants when he attacks windmills.
Just then they came in sight of thirty or forty windmills that rise from that plain. And no sooner did Don Quixote see them that he said to his squire, "Fortune is guiding our affairs better than we ourselves could have wished. Do you see over yonder, friend Sancho, thirty or forty hulking giants? I intend to do battle with them and slay them. With their spoils we shall begin to be rich for this is a righteous war and the removal of so foul a brood from off the face of the earth is a service God will bless."
"What giants?" asked Sancho Panza.
"Those you see over there," replied his master, "with their long arms. Some of them have arms well nigh two leagues in length."
"Take care, sir," cried Sancho. "Those over there are not giants but windmills. Those things that seem to be their arms are sails which, when they are whirled around by the wind, turn the millstone."
The figurative reference to tilting at windmills came a little later. John Cleveland published The character of a London diurnall in 1644 (a diurnall was, as you might expect, part-way between a diary or journal):
"The Quixotes of this Age fight with the Wind-mills of their owne Heads."
The full form of the phrase isn't used until towards the end of the 19th century; for example, in The New York Times, April 1870:
"They [Western Republicans] have not thus far had sufficient of an organization behind them to make their opposition to the Committee's bill anything more than tilting at windmills."