The gunmen were in the car when officers tried to arrest them in a quiet estate in Castleblaney, Co Monaghan, on Monday evening.
The two men pulled a weapon on the gardaí and threatened them before taking the driver hostage and ordering him to drive away.
There was a chase across the Border that ended when the Police Service for Northern Ireland (PSNI) intercepted the vehicle and arrested the men.
The hackney driver, aged in his 40s and with a grown-up family, was said to be traumatised by the incident. Local sources said he was well known and liked in the area and had only recently set up his hackney business.
Sources said the gunmen were not from the area.
The drama unfolded in front of children and parents in the Ardnalorgan estate when gardaí searched a house at around 8.20pm on Monday.
A Garda spokesman said a 38-year-old woman in the house was arrested for possession of the firearm.
About 10 minutes later the two men arrived in the hackney into the estate and stopped a short distance away. Gardaí then made an attempt to arrest them.
Witnesses said gardaí tried to handcuff one man when the second pulled a gun.
The Garda spokesman said: “There was an attempt to arrest two males in a taxi in Ardnalorgan at approximately 8.35pm. They threatened gardaí with a gun and forced the taxi driver to drive away.”
The hackney sped away, pursued by several Garda cars. It is thought the driver was directed to drive out the Monaghan road and take a number of byroads before heading to the Border on the Keady road.
Pursuing gardaí alerted the PSNI, which intercepted the car at Keady, 16km from Castleblaney.
Two men, aged 19 and 39, were arrested and taken to Armagh Station. A PSNI spokesman said they were assisting police with their inquiries. “They can be held for an initial 36 hours, however this can then be extended by a court.”
Castleblaney Sinn Féin town councillor James Cunningham said residents in the estate were shocked.
“They are very distraught. They are good people, those living in Ardnalorgan. The likes of this has never happened there before. There are a lot of young families there. There were children in the area at the time, so parents are shocked.”
His thoughts went out to the hackney driver. “He is a very quiet gentleman, highly regarded in the area.”