The only logical and direct way to get from Lagos to Morocco via Algeciras on a budget is by bus via Seville.
1) Lagos to Seville (Price one way € 20:00)
Take the twice daily coach service from Lagos to Seville Plaza das Armas bus staion.
Lagos Sevilha 06:30 13:00
Lagos Sevilha 13:45 20:15
2) Seville (Prado ) to Algeciras (Fares unavailable but will not be expensive.)
There are at least two companies operating this route:
TG Comes
Timetable here: http://www.tgcomes.es/horarios_33.htm
Linesur also operates this route but no online timetables.
You will need to get a local C4 bus between Estacion Plaza das Armas to El Prado Bus Station which runs from just after 6 in the morning till 23:30.