It’s no secret that San Francisco is beset with all manner of troubles these days, from rampant homelessness to terribly unsanitary conditions in much of its prime locations. Yet its huge hills and beautiful historic architecture still hold a magical allure for millions, and a young actor-writer named Jimmie Fails makes a dramatic stand for its preservation in the stunning new drama “The Last Black Man in San Francisco.”

Fails has come out of seemingly nowhere with the film, in which he plays a somewhat fictional version of himself and co-wrote the story with his best friend and director, Joe Talbot. The story follows Fails and his best friend, Monty (Jonathan Majors), as Jimmie tries desperate and inventive measures to reclaim his childhood home after 12 years when its owners are forced to leave the premises.

Jimmie has had the deck stacked against him his entire life, with a mother who abandoned him years ago and a father who is a former junkie and subsists by making and selling pirated DVDs in a dingy hotel room. Monty is stuck working in a fish shop while dreaming of becoming a playwright, and spends much of his time outside of work listening to the conversations and arguments of the people he sees on the streets around him.

When Jimmie realizes that the older white couple who took over the house when his family fell apart are being evicted due to a familial property dispute, he and Monty break in and start squatting there. He has always been told his grandfather built the fantastical house, and even manages to reclaim his grandfather’s assortment of odd furniture and other possessions to fill its massive empty space.

On the one hand, this brings Jimmie great happiness. On the other, it also creates a slow-building tension as they struggle to remain unnoticed and wonder when the other shoe is going to drop.

“Last” doesn’t rely much on conventional narrative, but rather is a mesmerizing visual poem and mood piece that grabs viewers from the start and never lets go. Co-writer and director Joe Talbot, the real Fails’ real-life best friend, kicks things off with an awe-inspiring opening sequence in which Jimmie and Monty hop on the same skateboard and soar through the streets of San Francisco on their way to work.

As they zip through the streets and soar up and down its incredible hills, numerous images of the people they pass are freeze-framed or slow-motioned as they stare at the two young friends flying by. This visual trick and many others are employed by Talbot throughout the film, creating a unique look from start to finish that recalls and even surpasses the dazzling cinematography of Spike Lee’s visionary early work.

With Emile Mosseri’s stirring musical score that combines orchestral power with a jazzy undertone, “Last” becomes a feast for the senses. Fails is making his literal feature film debut here as both writer and actor, and the result caused a sensation at this year’s Sundance Film Festival.

In fact, The Hollywood Reporter critic Todd McCarthy regarded it as “by far the best narrative film I saw at Sundance…Every scene is fresh and unpredictable, visual poetry and realism are exquisitely woven together.” Such high praise is richly deserved, and if you’re looking for an intelligent and compelling film amid the bombast of summer blockbusters, this is likely your best bet of the season.

“The Last Black Man in San Francisco”: A