Somewhere between Avalon and the Haywards Hill interchange in the Hutt, another Holden Commodore pulled up alongside Riwai's car.
The two drivers then accelerated north on the highway, with Riwai reaching the speed of 212km/h. The other driver allegedly reached 186km/h.
There were other vehicles on the road at the time but defence lawyer Chris Nicholls said there were not many, and nobody had to take evasive action as the cars sped past.
A police patrol spotted the two cars racing and pursued them, stopping Riwai near Silverstream and arresting him.
The other driver, 38-year-old Jason Leslie Campbell, was stopped a short time later in Upper Hutt and was also arrested.
Both drivers had their licences suspended for 28 days and their cars were impounded.
"He thought he recognised a person in another vehicle and thought that person was pursuing him," Nicholls told the court.
"He thought that person was from his past and, perhaps impulsively, started to speed up to get away from that person."
"He didn't try to get away from the police or anything like that," Nicholls said.
"It wasn't like the boy racers that appear before the courts that congregate at the Melling lights and intentionally get into a race."
Riwai pleaded guilty in July to operating a vehicle in a race or exhibition of speed.
Campbell allegedly told police he was driving in convoy with Riwai, and that his car could not reach the speed he was accused of driving at.
He has pleaded not guilty to the racing charge and will reappear in court at a later date.
Judge Tompkins said Riwai had a history of dangerous driving and other driving-related charges, and was even imprisoned in 2016 for a driving incident.
He labelled the street racing offending as "extremely dangerous".
"Despite his own inflated views of his skills as a driver, [he] presents as ongoing hazard to all other road users."
He sentenced Riwai to two months of home detention and 18 months of disqualification from driving.
The maximum sentence is three months in prison.
Riwai's sentencing comes a couples of months after two "lunatic" motorcyclists were spotted riding at speeds above 300km/h south of the Rimutaka Range.
They were seen on June 2 travelling at 247km/h on State Highway 2, and upon realising they'd been seen, accelerated to more than 300km/h.
Upper Hutt mayor Wayne Guppy said the speeds the motorcyclists were going was "absolute lunacy".
In 2016 a learner motorcyclist was also caught doing a "suicidal" 232km/h while trying to flee police.
The rider was wearing shorts and had a suspended learner licence when his speed was clocked on a Waikato road.
Stu Kearns, former head of the Waitematā Serious Crash Unit, told the Herald at the time that 232km/h was a "suicidal speed" and was certainly among the highest he had heard of in New Zealand.
"A rider in shorts, even leathers, wouldn't survive an impact at that speed. All his bones and organs would be just mush by the time he came to rest."