More than four months after its owner died, a dog still refuses to leave the entry of a hospital in Sao Paulo, Brazil.

The dog's owner, a homeless man, was stabbed in a local park and rushed to Santa Casa de Novo Horizonte medical centre where he died from his injuries, according to local media reports.

Following the fatal incident, the dog chased the ambulance carrying his owner and has waited at the doors of the medical centre ever since.

Hospital staff — who have provided food and water for the loyal companion — said the dog, whose name is unknown, has never tried to enter the building.

It sits quietly outside waiting for his master.

Local resident Cristine Sardella shared two images of the dog on her Facebook page on February 27, telling the story of his then-four-month wait, with her post going viral.

"We have lots to learn from the animals," her post read. "He waits for him in vain, but the love he has for his owner is eternal."

Loading

She first noticed the dog when visiting for an appointment.

"He would get up to let people pass by, very politely, and then lay right back down again," Ms Sardella, a local lawyer, told animal lovers website The Dodo.

Ms Sardella said she arranged for the dog to be picked up by a rescue organisation.

But it escaped within days and made his way back across the city, walking over three kilometres to get back to the hospital.

The hospital's director Osvaldo Sobrinho, told The Dodo they were arranging for the dog to be seen by a veterinarian and vaccinated, and a staff member was waiting to adopt him if and when it decides to leave its vigil.

It is not the first story of a dog showing unwavering loyalty to its owner.

A Japanese pooch named Hachiko famously waited almost 10 years at a train station for his owner who died after leaving it on the platform in the 1920s.

A bronze statue stands at Shibuya Station in Tokyo commemorating its loyalty, while near Gundagai, Australia's own Dog on the Tuckerbox memorialises a drover's faithful dog who guarded its owner's tucker box until death.