There was one flat at the front and his ex-partner's at the back flat.
The group then went to a nearby hotel and continued drinking.
Te Rata then got into an argument with his partner and when she told him to go home, he kicked her in the thigh.
When the hotel staff locked him out, he smashed a window trying to get inside.
Unsuccessful, he headed back to his partner's flat where he poured petrol around her house and lit it on fire.
The fire quickly spread, causing "extensive damage" inside the house, the court heard.
It then made its way through the roof space to the front flat.
Te Rata alerted the person living in the front flat.
The back flat was extensively damaged and it was rendered "uninhabitable".
The front house also had damage.
Judge Bill Hastings said he accepted Te Rata's actions were "spontaneous following an argument at the hotel".
"An aggravating factor in this case was the flat was made uninhabitable and the fire posed a risk to people living in the flat."
But he acknowledged Te Rata warned the person at the house.
But his pre-sentence report was "reasonably negative", Judge Hastings said.
He said the 32-year-old failed to show remorse and "continued to minimise the gravity" of his offending.
Ten days after he lit his partner's flat on fire, Te Rata was driving on Main Rd in Wainuiomata, Lower Hutt where he failed to stop for a police car.
He pulled over for a "short period of time" but then drove off again.
Ten minutes later, Te Rata deliberately swerved his car into the right hand side of a police car.
A short time later, he struck another police car before being stopped.
Te Rata was also disqualified from driving for one year.