Martin Edgar, 32, of Millburn Avenue, Dumfries, was also banned from driving for three years and ordered to re-sit a test before regaining his driving licence.
In court on Wednesday, Sheriff Brian Mohan told Edgar: “You have 21 different court appearances for road traffic offences and here you have two cases of trying to outrun the police putting yourself and others at risk.”
Edgar admitted one charge of dangerous driving in January and another of careless driving the following month.
Fiscal depute Lyndsay Hunter told the court that on the first occasion police were alerted to look out for a particular car and when they saw Edgar on the A75 road near the River Nith overbridge they moved in and put on blue lights and siren.
But she said they were repeatedly ignored as he repeatedly drove onto the opposing carriageway, overtook when it wasn’t safe to do so and caused other drivers to take evasive action before going out of sight.
The second chase started in Annan and went onto the B721 Annan to Gretna road in Dornock and Eastriggs when he drove carelessly at speed and again overtook when it wasn’t safe to do so.
Sheriff Mohan said there was no alternative to a prison sentence.