The manhunt that resulted in the arrest of a suspect in a series of knife-wielding robberies of small businesses on Long Island and in Queens was “a model of how law enforcement should work together,” officials said Wednesday.

Nassau County Executive Edward Mangano said heroin may have been the suspect’s motivation. Police identified the suspect as Khalif House, 24, of Hempstead.

“Hopefully with his arrest, these robberies have come to an end,” Mangano said.

Officials said they are looking at 27 cases — 13 in Nassau, four in Suffolk, and 10 in Queens — the suspected robber may have been responsible for. The pattern of robberies officially began March 1, but may have actually started in February.

House was arrested Wednesday after an extensive search of a residential area in Floral Park by multiple law enforcement agencies.

“Essentially this is a model for how a case should be worked when you are working with several different law enforcement agencies,” Suffolk Police Commissioner Timothy Sini said.

A team of police officers from the 105th Precinct in Queens was watching a Dunkin’ Donuts on the border of Nassau and Queens when they noticed a man fitting the description of the serial robber, a high-ranking NYPD official said Wednesday afternoon.

When police approached, he fled on foot, the official said. Cops searched the area and noticed a car that fit an earlier description of one used in at least one of the robberies.

Police approached car and there was a woman in it who was nervous — and she ultimately gave police information on the man, the official said.

It turned out the man apparently spent the night in the basement of a house he broke into, the official said.

Floral Park Police Commissioner Stephen McAllister said Floral Park police received a 911 call from a resident on North Tyson Avenue, who said a man was sleeping on his couch about 7 a.m. Wednesday, prompting a massive search and the ultimate arrest.

“We believe we may have apprehended the suspect,” McAllister said.

“We got a phone call this morning from a resident that an individual not known to him was sleeping on his couch. When he sees the owner come down, he flees the house.”

Floral Park cops responded, not knowing the possible connection to the serial robbery suspect, the commissioner said.

“Our officer gave chase,” McAllister said. “He hopped a fence and disappeared on us in this area. Nassau came, the NYPD came, and we’ve been searching for him for the last few hours.”

At one point the man tried to break into a red van parked in the rear parking lot of a gym on Jericho Turnpike at Van Siclen Avenue, McAllister said.

McAllister said the suspect was hiding behind a cellar door at the rear of a home on Van Siclen Avenue and that homeowner called 911 and the arrest was subsequently made.

.

Bill O’Keefe, a retired electrician who lives on North Tyson Avenue in Floral Park, said he woke up Wednesday morning and found the stranger on his living room couch.

“I see somebody moving on my couch,” O’Keefe, 75, said Wednesday. “He saw me, I saw him. . . . I said, ‘What the hell you doing here?’ and he took off.”

O’Keefe said the man, who didn’t say a word, ran through his living room, dining room and out the back door. O’Keefe said he called 911 and followed him down the block, and pointed in the direction he fled for responding Floral Park cops.

O’Keefe said he thinks the man got in his house through an unlocked back door. He went to bed about 10:30 p.m. Tuesday night and didn’t hear any noises, he said.

“I didn’t even think about being afraid,” said O’Keefe, as he recounted the story hours later for reporters outside his home.

But he said he’s learned a lesson: “I’m going to lock my doors.”

And he had a message for cops. “I hope there’s a $100,000 reward,” O’Keefe said. “I’m claiming it.”

The search came less than 24 hours after the attempted robbery of a Dollar Tree store on 14th Avenue in College Point.

Wearing sunglasses and a black handkerchief as a mask, the suspect in that case demanded money, but ran off without getting anything, police said.

It’s unclear why the suspect ran — or if he was frightened away — without notching another successful robbery since March 1, the spokesman said.

Police said after Tuesday’s failed robbery that the suspect may have jumped into a gray Nissan.

Since May 11, the serial robber has hit seven small businesses in Queens; he has also robbed 13 Nassau stores and four in Suffolk, mostly Subway sandwich shops, Dunkin’ Donuts, Carvel ice cream stores and 7-Elevens, police said.

The Dollar Tree attempt is the first time the serial robber has been known to fail, according to police.

The FBI has joined forces with NYPD, Nassau police and Suffolk police in an effort to nab the robber, who has become more daring recently.

He struck a Subway in Far Rockaway on Monday, entering the fast-food restaurant at Beach 20th Street about 9:30 p.m. and taking $600 from the cash register, police said.

The suspect in the pattern has been described as 25 years old, about 6 feet tall with a medium build, most often wearing a dark hooded jacket, blue jeans and tan work boots. He usually covered his face with dark sunglasses and a dark cloth, police said.

Witnesses have described him carrying a large butcher knife, which police have said is uncommon in this type of crime.

With Laura Blasey, Anthony M. DeStefano and Ted Scala