How long did the drought that Elijah prayed for really last? James and Luke say the drought lasted for three and a half years.


  Elijah was as human as we are, and yet when he prayed earnestly that no rain would fall, none fell for three and a half years
  (James 5:17 NLT)
  
  "Certainly there were many needy widows in Israel in Elijah's time, when the heavens were closed for three and a half years, and a severe famine devastated the land.  (Luke 4:25 NLT)


But according to the actual account in the Old Testament the drought was not even a full three years.


  Now Elijah, who was from Tishbe in Gilead, told King Ahab, “As surely as the LORD, the God of Israel, lives—the God I serve—there will be no dew or rain during the next few years until I give the word!”   (1 Kings 17:1 NLT)
  
  Later on, IN THE THIRD YEAR of the drought, the LORD said to Elijah, “Go and present yourself to King Ahab. Tell him that I will soon send rain!” 
  (1 Kings 18:1 NLT)
  
  And soon the sky was black with clouds. A heavy wind brought a terrific rainstorm, and Ahab left quickly for Jezreel     (1 Kings 18:45 NLT)


So it was in the third year of the drought that the rains came ending it.

Why do Luke and James both say the drought lasted 3 years  and 6  months?
There are two common ways to explain this:

The &quot;third year&quot; refers to the third year of Elijah's stay in Zarephath, following a stay of some months at the brook Cherith (Adam Clarke, Barnes, Haydock, Keil and Delitzsch)
The &quot;third year&quot; refers to the time of Elijah's exile, which did not begin until the dry period had already been underway for six months (Jamieson, Fausset, and Brown; Thomas Coke)

In both cases, it's important to note that the text does not actually say &quot;in the third year of the drought.&quot;  See, for example:

After many days the word of the Lord came to Elijah, in the third year, saying... [ESV]
And it came to pass after many days, that the word of the Lord came to Elijah in the third year, saying... [KJV]
Now it happened after many days that the word of the Lord came to Elijah in the third year, saying... [NASB]
After a long time, in the third year, the word of the Lord came to Elijah... [NIV]

Many modern translations add &quot;of the drought&quot; or &quot;of the famine,&quot; but it's not actually in the text.
Third year of Elijah's stay in Zarephath
One explanation for the alleged contradiction depends on this: rather than the &quot;third year of the drought,&quot; the text is referring to the third year of Elijah's residence in Zarephath (1 Kings 17:9), where is staying at the end of 1 Kings 17.
Prior to this, but after the beginning of the drought, Elijah lived by the brook Cherith for an unspecified length of time (1 Kings 17:5).
Thus, if he lived at Cherith for some months, and this time is added to the 2+ years he lived in Zarephath, the time mentioned by Jesus and James (3 years, 6 months) is not necessarily contradictory to the 1 Kings account.
Keil and Delitzsch call this the &quot;most simple and natural&quot; understanding:

The time given, &quot;the third year,&quot; is not to be reckoned, as the Rabbins, Clericus, Thenius, and others assume, from the commencement of the drought, but from the event last mentioned, namely, the sojourn of Elijah at Zarephath. This view merits the preference as the simplest and most natural one, and is shown to be the oldest by Luke 4:25 and James 5:17, where Christ and James both say, that in the time of Ahab it did not rain for three years and six months. And this length of time can only be obtained by allowing more than two years for Elijah's stay at Zarephath.

Third year in exile
Jamieson, Fausset, and Brown, among others, take a different approach.  They argue that the two periods of rain in ancient Israel normally occurred in March and October, and that the king's anger would have driven Elijah away only after these rains failed:

The early rain fell in our March, the latter rain in our October. Though Ahab might have at first ridiculed Elijah‘s announcement, yet when neither of these rains fell in their season, he was incensed against the prophet as the cause of the national judgment, and compelled him, with God‘s direction, to consult his safety in flight. This was six months after the king was told there would be neither dew nor rain, and from this period the three years in this passage are computed.

Summary
Either approach addresses the apparent contradiction, and some commentators, such as John Wesley, mention both and do not express a preference.