The firm beat Carillion, Kier, Morgan Sindall and Mace to take the job, which once built will become a new regional headquarters and signalling centre housing up to 2,000 staff.
The new hub will control rail signals across the entire Wessex route, which covers rail track from London Waterloo, down to Weymouth, and includes Guildford, and Salisbury.
Alongside the signal centre, Network Rail will create a workforce development centre, and welding training centre with a 140m external practice track.
BAM will start work on the six acre site near the town centre in August after gaining planning approval.