There are two common ways to explain this:
- The "third year" 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 "third year" 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 "in the third year of the drought." 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 "of the drought" or "of the famine," 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 "third year of the drought," 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 "most simple and natural" understanding:
The time given, "the third year," 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.
Either approach addresses the apparent contradiction, and some commentators, such as John Wesley, mention both and do not express a preference.