A banned driver became involved a high-speed car chase as a police driver and a female motorist had to swerve to avoid crashing.
Christopher McMahon, 33, of Garden Place, Townhill, appeared from custody at Dunfermline Sheriff Court and admitted two offences of driving while disqualified, one dating back to last year.
The latest incident took place on streets through Dunfermline and Townhill on Sunday.
McMahon drove dangerously and at grossly excessive speeds on Halbeath Road, Whitefield Road, Kingseat Road, Chamberfield Road, Kent Street and Garden Court.
He failed to comply with road markings, repeatedly travelled on to the opposite carriageway and overtook queueing traffic when it was not safe to do so.
His actions forced other motorists to take evasive action to avoid a collision.
Depute fiscal Mina Poppius said that at 5.50pm McMahon was spotted by police officers on patrol.
When they activated their sirens and blue lights McMahon accelerated away.
He was swerving into the opposing carriageway, including through a blind bend on one occasion.
McMahon also shot past a female driver who had stopped and was about to turn right.
Ms Poppius said: “She was alarmed and his car was so close that her vehicle shook.”
Officers called for further assistance and then a police car had to brake sharply to avoid a collision.
When McMahon continued to accelerate onto Main Street, the police decided not to try to keep up with him but continued to follow.
He then took a blind left-hand bend on the wrong side of the road.
The police were given information by an onlooker about where McMahon had gone.
They found his car parked outside a house but with no one inside. They then saw his head popping out from a nearby house.
When he was arrested, he was found to be in possession of diamorphine.
Defence solicitor Ian Beatson said his client has been a long-term heroin user.
The reason for the latest offending was “he was intending to visit someone, was running late and foolishly drove the car”.
McMahon further admitted that on August 19 in Main Street, Townhill, he drove while disqualified.
He also admitted driving while disqualified and without insurance in Gellatly Road, Dunfermline, on January 17 last year. McMahon failed to turn up for a court appearance relating to this offence in June last year and a warrant was granted.
Sheriff Simon Collins jailed McMahon for 18 months and banned him from driving for 10 years.