Libya divides broadly into two climatic zones: the Mediterranean coast and the Saharan interior. The best time to visit depends on which you're prioritising.
Spring (March to May) is the ideal time for the coast and the archaeological sites. Temperatures in Tripoli and Benghazi hover between 18°C and 25°C — warm enough to enjoy the ruins without being punishing. Wildflowers briefly colour the Jebel Akhdar. Avoid late April and May if ghibli season is early: hot sand-laden winds can blow in from the desert with little warning, reducing visibility and making outdoor time unpleasant.
Autumn (October to November) is the other sweet spot, with similar temperatures and less wind. The sea is still warm through October if you want to combine ruins with a swim.
Winter (December to February) is the right season for Fezzan and the deep Sahara. Days are cool and clear, nights can be cold (near zero at altitude), but you'll avoid the brutal heat that makes desert travel dangerous in summer. The coast gets its rain in winter — nothing heavy by most standards, but Tripoli can be overcast and chilly.
Summer (June to September) is punishing inland, with temperatures above 40°C in the Sahara and high humidity on the coast. Not recommended for ruins or desert travel.
Security conditions are the bigger variable than weather. Check government advisories in the weeks before any planned trip — the situation in Libya can shift quickly.