Gibraltar is famous for being the last remaining colony in mainland Europe. Given to the UK in the Treaty of Utrecht of 1713, it was an important military base for many years. Today it is largely a frustration to everyone involved: Spain wants it to be Spanish, the Gibraltarians want to remain British and the UK is tired of defending a place it couldn't care less about. For the rest of us, it is home to a great big rock and some cute monkeys (as well as some cheap shopping).
Border Control: Do You Need a Passport?
Because of Gibraltar's political situation, border controls are strict (some say spiteful) and tediously long. Driving from Spain to Gibraltar is not recommended and no buses will take you across the border. (They all stop at La Linea de la Concepción, the town on the Spanish side of the border.) For the most trouble-free visit to Gibraltar, take a guided tour.
Remember that Britain (and so, Gibraltar) is not in the Schengen zone, Europe's border-free zone. You will need your passport to enter Gibraltar and, in some cases, a visa.
Guided Tours From Malaga
There are two guided tours from Malaga to Gibraltar. Both involve bus transport to the border, where you will be dropped off (with your guide) and accompanied into Gibraltar. At the end of the day, your driver will be waiting for you. This is infinitely more convenient than having to book a bus from the Spanish side, as you can never know how long the border crossing will take.
One guided tour is billed as a 'shopping tour', but is basically a no-thrills shuttle service to get you to and from The Rock (which is worthwhile, for the reason explained above). There is also a 'sightseeing tour', which includes a tour of the rock and a visit to the monkeys.
How to Get There by Bus and Train
Walk across the border from Gibraltar into the Spanish town of La Linea de la Concepcion to take the bus to Malaga. As explained above, coordinating your bus with the time-consuming border controls is logistically awkward.
The bus is run by Portillo and takes about three hours (very slow compared to a guided tour bus).
How to Get There by Car
The 130km drive from Gibraltar to Malaga takes over one-and-a-half hours, traveling mainly on the AP-7. Note that the AP-7 is a toll road.
The Costa del Sol separates Gibraltar from Malaga, means that the only stops along the way are beach towns.
The only worthy addition to your itinerary along this route would be to take a detour via Ronda. However, this adds quite a lot of time to your journey and would require overnight accommodation in either Ronda or Gibraltar.