1) Flights - It looks like Ryanair have pulled the plug permanently on this route. See this article on my blog.
http://barlaventostravelblog.blogspot.com/2007/11/ryanair-faro-mardid-route.html
However, don't despair you do not need to go via Gatwick.
Vueling.com and Easyjet.com operate flights from Madrid to Lisbon. From Gare de Oriente, near the airport you can get a Renex Bus to Lagos for +- Euro 18.00 or a train t.o Lagos for not much more.
2) Buses from Madrid to Lagos. The cheapest route is probably to take a Socibus bus from Madrid to Seville and connect with the twice daily DAMAS/EVA service to Lagos. Note this operates only on weekdays in winter.
If you got the overnight Socibus service from Madrid at 22:00 arriving at 05:15 you could connect with the 07:30 DAMAS bus from Seville to Lagos arriving at 12:00.
Total cost should not be more than Euro 60.
It is possible to Madrid - Lisbon - Lagos via Lisbon Gare de Oriente but this route tends to be more expensive.
For more info, see http://cubsur's www.algarve-bus.info.