A man who drove to a Manhattan taxi driver’s cab and attempted to rob him early Sunday morning is recovering in a hospital, officials said.

The cab driver, who works for cab companies across the city, stopped to pick up a passenger around 1:45 a.m. near East 57th Street and Central Park West, at 30th Street, but the 32-year-old man in the car started arguing with him, a police source said.

The cab driver told the man the driver had stolen his car and wanted the money back, police said.

The suspect, a black man who is 6 feet, 1 inch tall and weighs about 200 pounds, started running toward the East 59th Street and Central Park West subway station. He got into a red Mercury Mountaineer pickup, and slammed the vehicle into a pillar, officials said.

The man tried to grab the cab driver’s gun and get in the cab, but the cab driver didn’t have his, cops said.

As the man tried to grab the cab, a passenger in the back of the cab got out and ran over to the driver, yelling “he didn’t do it, he didn’t do it.”

“He was trying to rob the driver and get money out of the taxi, but he didn’t get there. I think he just ran away,” said the taxi driver, who wished to remain anonymous.

The taxi driver then went over to the suspects’ area and tried to set up a phone call with the cab driver, but the suspect ran out the back door and into an apartment building on Central Park West, between First and Second avenues, police said.

As the suspect got back into the cab, the cab driver put the cab in reverse and called 911. The officer who pulled up, a 31-year-old man who is black, chased the suspect but was not injured, cops said.

The suspect was located near 36th Street and East 43rd Street. He had a black passenger whose age was not immediately clear, officials said.

The man and the suspect got into another cab and were stopped by the cab driver, who talked to the suspect and took his money, police said.

After the cab driver told the suspect he had nothing to hide, police arrested him and took him to the 9th Precinct. The man told the cab driver he was OK but didn’t know why he was in the cab, police said.

An officer also checked the cab’s driver’s manual to find the car’s license plate number and traced it to the cabdriver.

When he was put in custody, the suspect had a gun and fired, police said.

He is being treated for minor injuries at Bellevue Hospital.