I highly recommend taking the AVE. It is fast and affordable. If you book it enough in advance, you can easily get it to around $54 euros. Since you are already in Spain, there is no immigration but there is baggage clearance. You can not take ANY knives in your luggage or any other sharp objects. Renfe does scan baggage. No need to pay for the first class ticket, the train is really nice. When You arrive in Madrid, your ticket will give you a ride on the Circanias for no additional charge. You will then take the Circanias to the Plaza Del Sol station. Be mindful that the metro stations in Madrid vary in whether they have an escalator, so don't bring heavy luggage!!! Some stations have them, or they may have them to one platform but not others - it is a pain! Depending on which exit you take at Plaza Del Sol, there is one that does have a lift, but the other does not.
Look online about traveling from the airport to the train station. I am sure it is easy.
I would arrive at the train station at least 20 minutes ahead of boarding.
I would take the train over another flight, but you can also check Vueling, they are having a sale right now - purchase two tickets with a discount. Hurry on that, it won't last long!