On the evening of July 14, director Peter Berg was in Nice, France, working on a documentary about pop star Rihanna, when a mentally unstable, Tunisian-born man drove a cargo truck into a crowd celebrating Bastille Day, killing more than 80 people and injuring hundreds.

“We were right there,” the wiry, perpetually moving Berg recalled on a recent afternoon in his production offices in West Los Angeles, having come straight from his daily workout at a nearby boxing gym he owns. “The truck drove right past our hotel. We saw people running toward it, civilians running with police, people picking up people, instantly going into a version of the best of ourselves.”

As it happened, just weeks earlier Berg had finished shooting a film about another horrific act of terrorism: the 2013 bombing near the finish line of the Boston Marathon that killed three people and injured hundreds of others.

Berg's new film, “Patriots Day,” which stars Mark Wahlberg, chronicles the Boston Marathon attack and the intense four-day manhunt to bring the perpetrators, Tamerlan and Dzhokhar Tsarnaev, to justice. The film follows closely on the heels of the release of Berg's real-life disaster drama “Deepwater Horizon.”

“Patriots Day” arrives in theaters 3 1/2 years after the events it depicts and after a deeply polarizing presidential election in which difficult questions of how to respond to terrorism came dramatically and divisively to the fore.

With the film touching on many of these hot-button issues, it's inevitable that audiences and critics will see “Patriots Day” through a political lens. But Berg insists “Patriots Day,” which has drawn generally strong reviews, is apolitical.

“There are no atheists in a foxhole, and there were no political parties on Boylston Street 12 seconds after the bomb went off,” he said. “Nobody was asking for people's political affiliation when they were picking them up and running them out of there.”

At 52, Berg has had a restless, peripatetic career. After turning in his 30s from acting to writing, directing and producing, he has found his greatest fulfillment with character-based, action-filled dramas based on true stories like 2004's “Friday Night Lights,” 2013's Afghanistan war film “Lone Survivor” and “Deepwater Horizon” and “Patriots Day.”

“That feels like a real sweet spot for me creatively,” Berg said. “I like nonfiction. I took journalism in college, and I love doing research, interviewing people, walking around in the world where something happened.”

At a time when Hollywood is struggling to understand its place in relation to the kinds of voters who supported Donald Trump, Berg's muscular yet emotional paeans to people from what Hollywood might broadly consider flyover country — high school football players in small-town Texas, cops, Navy SEALs, oil rig workers — have placed him ahead of the curve.

“When we made ‘Lone Survivor,' a lot of the guys out here in Hollywood were very skeptical about a movie that was blatantly supporting troops,” said Berg, whose own late father was a Marine who served in the Korean War. “They predicted maybe we'd make $15 million opening weekend, and we opened to almost $40 million. And it was almost exactly the same surprise that I saw when Trump won.” (“Lone Survivor” wound up making $155 million worldwide.)

Boston native Wahlberg, who also starred in “Lone Survivor” and “Deepwater Horizon,” says “Patriots Day” carries no particular ideological agenda but was simply born out of a desire to show how his hometown had come together in response to the bombing.

“We didn't want to get into any of the political stuff; we really wanted to just tell the story of these amazing people,” said the actor, who is also a producer on the film. “But the movie will certainly make people ask questions or debate certain things, and that's never a bad thing.”

When it comes to politics, Berg considers himself a centrist with no allegiance to any party. “I found when I did ‘Lone Survivor,' my more liberal friends were attacking me for being sympathetic with the NRA, and with hardcore Republicans, and a lot of the Republicans I work with were accusing me of being some Hollywood leftist,” he said. “I just said, ‘I'm going to ignore all of this.' I believe there are issues and themes that transcend politics.”

josh.rottenberg@latimes.com