Nathan Myles, 23, from Arbroath, sped along the A92 dual carriageway between Carnoustie and Dundee racing 22-year-old Ryan Ross in April.
Sheriff Gregor Murray said it was "five minutes of madness".
Sentence on Myles was deferred for reports at Forfar Sheriff Court. Ross, from Dundee, was fined Â£1,000.
Both admitted dangerous driving.
The pair had never met before and were pulled over by police in an unmarked car.
Fiscal depute Hannah Kennedy said they both braked frequently as they tailgated other cars with their speeds reaching 105mph.
Ian Flynn, defending Myles, said:  "His only mitigation is that he was a stupid, stupid person on that day."
David Duncan, for Ross, said there was "no connection" between the pair "other than their standard of driving".
He said: "He describes his behaviour, quite appropriately, as madness and there is no better explanation than that."
The sheriff said: "Any person who drives like this with young children in the car like you did faces potential imprisonment."
A driver who raced another car at more than 100mph while he had an 18-month-old child on board has been warned he could be jailed.