Use a rigid tool such as an old wood chisel to flick off any flakes of rust. Follow the entire extent of the pipe that has been rusted with the tool, scraping away any scale and solid formations until the undamaged surface of the pipe is revealed. Determine whether the extent of the pitting suggests replacing the entire pipe would be advisable; any corrosion that has bored into the metal of the pipe -- rather than being merely superficial -- indicates that replacement is advisable.
Use a wire brush to scour the pipe until it's shiny and clean.
Follow the wire brush with course, 60-grit sandpaper to get into smaller crevices; sand until there is only a light coating of brown dust on the pipe.
Use a spirit-based cleaner to wash down the pipe. Use turpentine, mineral spirits or similar, applying them first to a clean rag then wiping the pipe. These fluids will remove atmospheric contamination such as grease from the pipe, along with any remaining rust flakes or dust that have been abraded off the surface but remained on the pipe.
Apply a proprietary rust converter when the pipe has dried, observing the manufacturer’s instructions. Rust converters chemically alter rust into a moisture-proof protective coating that can be left as-is or painted. Products include Rustoleum's (rustoleum.com) Rust Reformer and Microchem's (mrochem.com) BlackStar; these are available at home improvement and department stores and can be applied with a bristle brush or sponge brush.