We did this by firstly sanding down all the varnish (by hand) so that the paint would have something to stick too. You don't have to strip it all off but if you sand it well some will come off anyway (depending on how many layers of varnish their are). It's a really boring job.
Then we painted it all with an undercoat, followed by the gloss. We didn't paint the rail, but we did paint the spindles and the posts at each end. We haven't decided whether to re-varnish the rail or to paint in white to match the rest.