A suspect has been taken into custody as a day-long standoff at a Richmond Hill home, where a male believed to be armed and dangerous barricaded himself for most of the day, comes to an end.

Several loud bangs were heard and police could be seen running toward the house before emerging with the suspect, a young male in handcuffs wearing a white T-shirt with blood stains. Heavy smoke was also seen moments before the arrest.

In a tweet, York Regional Police said the "party is in custody" and the "situation has ended. It is safe for residents to leave shelter area."

The suspect is expected to be charged on Saturday.

Party is in custody & situation has ended. <br>It is safe for residents to leave shelter area. <br>Call takers will be calling you back to confirm <br>thank you for assistance<br>LD <a href="https://t.co/abw3uW2zTN">https://t.co/abw3uW2zTN</a> —@YRPDutyOffice

A male entered the residence earlier Friday morning after he allegedly shot at a police officer in Richmond Hill, York police say.

York Regional Police say the incident began around 10:30 a.m., when an officer made a traffic stop near the intersection of Bayview Avenue and Major Mackenzie Drive.

Const. Laura Nicolle said the driver of the stopped vehicle opened fire and the officer shot back, then the suspect fled into a nearby residence.

Nicolle did not provide any further details about the male and said it's not clear if he has any connection to the residence. There were no apparent signs of forced entry, she said.

"For something like this, where we do have a suspect who was willing to actually fire shots — in the middle of the day, in a very busy, crowded area — that's a very dangerous and concerning type of situation that requires every resource that we have available to us," Nicolle said.

She said officers tried to negotiate with the person inside the house, trying to get him out safely.

A police robot was sent in for a brief period Friday afternoon.

Homes in the area were evacuated as the standoff unfolded.

The Toronto police Emergency Task Force, which deals with high-risk situations, also helped at the scene.

A police tactical vehicle outside the house were a man has barricaded himself for several hours on Friday. (Jeremy Cohn/CBC)

Nicolle said it was "very fortunate" that the officer involved was not injured. No bystanders were reported to be hurt.

The province's police watchdog, the Special Investigations Unit, invoked its mandate, saying it was possible the male was hit by police gunfire.

Police taped off the gas station and closed the intersection for much of the day. Bayview Avenue is closed in both directions between Major Mackenzie and Old Markham Road.