Inside Uganda’s Bwindi Impenetrable National Forest, a gorilla brushes against my leg on her way to a new perch.

I’m trying to keep the proscribed distance of 20 feet, but the family of 15 gorillas ignores the theoretical boundary. When a female suddenly moves out of the thick green bush, there’s no time to scramble out of the way. My group’s ranger tells me to stand still until she passes, then beckons me out of the way lest she reverse course.

Even without that brush, our encounter with the gorillas is far closer than we had imagined — just as their total disregard for our presence is far greater. We might share 98.4 percent DNA with these linebacker-sized cousins, but by most appearances, they couldn’t have cared less.

The opportunity to spend an hour in the wild with one of the world’s estimated 35 gorilla families drew about 40,000 trekkers last year to Uganda, home to more than 50 percent of the mountain gorilla population.

I am glad I was one of them.

Gorilla-viewing tourism was launched in the late 1990s to create alternative employment to poaching. In Uganda, 20 percent of every permit fee — or $180 per visitor — goes to the local community. Jobs as hotel staff, drivers, rangers, guides and porters all go to locals.

Despite some persistent poaching and habitat loss, the plan seems to be working: Between 1989 and 2011, the number of individual gorillas grew from about 620 to about 880, according to Bas Huijbregts, African species manager for the World Wildlife Fund’s Wildlife Conservation Program. Data from the most recent census, in 2015-16, are still being analyzed, he says.

Gorilla-zone governments get their share: Uganda charges $600 per person per day for the highly coveted, date-specific permits. Rwanda recently doubled its fee from $750 to $1,500, with $150 per permit now going to the local community. The Democratic Republic of Congo charges only $450, but instability in the region makes it the least popular of the three, and the U.S. State Department warns Americans against visiting.

Baby on board

Getting to Bwindi National Forest requires a five- to six-hour drive on dirt roads. I’ve opted for the alternative: a 90-minute flight from Entebbe. A driver picks me up for a 60-minute drive to the hotel, through villages with mud-brick houses punctuated by pastel-painted churches, through the occasional herd of long-horned cattle.

My lodge, Mahogany Springs, sits just a mile from the park office. The proximity is good, because a gorilla trek requires an early start. By 8 a.m., all visitors holding this day’s permits have gathered at the park headquarters for orientation and assignment, a maximum of eight visitors per group. In the rainy season of May, crowds are less than full force; there are only five in my group.

Technology sets the direction. Since dawn, Bwindi’s park rangers have radioed with the trackers who watch over each gorilla family to gauge their locations and deter poachers. Their reports establish launch points for the day. But there are no promises about how long the search will take; some treks last the better part of the day. Despite the hefty price of a permit, there is no guarantee we’ll see gorillas at all.

We drive a few miles from park headquarters to the village of Nukoma. Omax, our ranger guide, is in the lead, followed by a rifle-bearing guard, a college intern and a trio of porters we’ve hired in the village as a way of supporting the local economy.

The mountain path runs next to the village church. Past the last windowless houses, their bricks cemented with mud; beyond a goat resting on a platform, above the reach of marauding red ants; through a blessedly shady banana grove; by an open hut where a handful of men carve wood into gorilla-shaped souvenirs. Buffering the village is a lush field of tea leaves, a cash crop with a bitter taste that creates a natural fence between humans and the great apes.

Even on the clear part of the path, the climb is steep. With thighs burning and sea-level lungs wheezing, we head slowly, slowly up the mountain.

We’re lucky. Just a few steps beyond the reach of the village boom box, the juveniles come into view. Omax watches as they clamber up a thatch of ficus trees, then jump from limb to limb. The gorilla family has traveled over the mountain ridge and down the steep incline far more quickly than our trackers, who lag a few miles behind. For now, the apes seem set in place.

Omax signals to drop the packs with the porters. We trudge through the low brush to begin our viewing in a clearing beneath the trees.

There, seemingly oblivious, sits the No. 2 male, Kalembezi, munching away on figgy fruits thrown down from the branches by the younger, lighter juveniles. Just up the slope, a female emerges through the green, a baby clinging to her back. Another with baby aboard shimmies down the trunk of the sturdy ficus. And finally, the silverback lumbers through the jungle and into view. We are close enough to hear the odd belch of a satisfied diner and the flatulence caused by a herbaceous diet.

A one-hour limit

Seeing the apes as human is no anthropomorphic leap. Palms are padded, giving way to four flexible fingers and a thumb used to break branches and brush off the figs. One of the babies keeps falling from its mother’s back. Another repeatedly wanders off into a low patch of ferns before being hauled back by his mother.

Kalembezi is messy, his mossy fur dotted with straw and the odd leaf. As the family’s No. 2, he keeps a slight distance from the others. His job is understudy, a backup in case Kabukojo, the silver-backed leader, gives way to age or illness. But Kabukojo is himself less than middle-aged in gorilla terms; Kalembezi could be in for a 20-year wait.

Despite the proximity, we feel perfectly safe, and in fact, dangerous encounters are almost unheard of. Visitors aren’t allowed contact with a troop until rangers and scientists have spent two to three years habituating a family, and because the two species can share diseases, humans aren’t allowed to visit if they are sick.

That’s not to say that the gorillas are always cheerful. Just this past summer, in Rwanda, a silverback charged a tourist group in a mock attack — typical behavior when gorillas feel crowded. Beyond the minor scrapes from slipping down the hillside, there were no injuries.

Other travelers have posted videos of a touchingly close encounter, when gorillas came into a camp. A recent Rwanda visitor has told us of a mother gorilla pulling the visitor’s husband back from wandering babies.

Fellow trekker Melissa Cameron of San Francisco has had this experience once before, during a previous visit to Uganda in 2006, when there was more bushwhacking involved in her hike and a three-hour wait before her group found the gorillas. While the rest of us were snapping away through long lenses, Cameron put her cellphone aside and simply sat down. “The best times are when you put the cameras down. That’s when the real magic happens ... Every time I crouched down to the ground, the gorillas would approach me and come sit down near me. At one point, one was literally 3 inches away.”

The gorillas are always in charge. To ensure their comfort, viewings are limited to an hour. The apes don’t need a Timex to know when time is up. A fellow lodge guest told of the silverback that stood on his haunches, beating his breast to signal that her group’s time was up.

In our case, the dismissal is less dramatic — but no less punctual. After almost exactly an hour together, the silverback quite literally turns his back on us, and the troop moves away.