If you pay to get out of your contract the Lord keeps the gear. You can keep the gear if you desert, but then you are outlawed and you can't get into cities and castles and everyone wants to kill you. It's a real pain and makes the game almost unplayable.
One way to get to keep the gear without being outlawed is when your Lord is defeated in battle. After you escape from the enemy, make your way to another Lord and hopefully he will say he is hiring mercenaries for an upcoming campaign. Or offer your services to a Ruler as a vassal. You can keep the gear you have and you are no longer obliged to the first Lord. If you do not become a mercenary or vassal, eventually you will be outlawed as a deserter when you fail to re-join the first Lord within the stated time limit.