Take lightweight oil and apply it over the chain. You can use WD-40, as it is known as one of the best oils available in the market, for fixing rust issue from metals. Make sure that you apply the oil all across the length of the chain. You can also rotate the pedals in order to make sure that the oil is placed all over the chain.
Now wait for several minutes, to allow the oil to soak in the chain. Take a rag and wrap it around the chain. Use this rug to thoroughly wipe off the oil, rust and mud from the chain. Once again, rotate the pedals and see if any part of the chain still has rust on it.
You can also inspect the chain deeply by checking each and every link. If you find any of them jammed due to rust, you can oil it heavily, to make it flex and wipe off the rust and the oil using a toothbrush. You can use any of your old toothbrush for this purpose.
Once again, apply the oil to the whole chain and leave it to soak. You do not need to wipe it off this time, as it will protect your chain to avoid catching rust again. You can practice this every time you feel that your chain needs oiling.
You should also make sure that the sprockets are free of rust. Otherwise, you will have to oil them too. You can apply the oil and wipe them off using a rug. When you will apply the oil to the chain, it will automatically be apply to the sprockets. However, it is advised that you should manually apply some amount on the sprockets too.