I f you’re like me, there are probably a lot of thoughts that run through your mind every time you descend into a Boston MBTA station:

Are the trains running?

Didn’t I see the guy next to me on “America’s Most Wanted”?

Will I get home before next Thursday?

You probably aren’t thinking you’re risking God’s wrath by traveling underground.

PBS’ engrossing “The Race Underground,” part of “American Experience” (Tuesday at 9 p.m. on WGBH), charts the herculean effort to build America’s first subway system — right here in Boston.

The one-hour documentary also serves as a bit of redemption to an imaginative inventor who always seemed to take a back seat to Thomas Alva Edison.

In 1882, visiting Naval officer Frank Sprague was not impressed by London’s subway. The coal-powered steam engines were wildly inefficient — and dirty and smelly.

He imagined a better way — with electric-powered motors — and spent the next few years developing his own patented motors and electric railway cars.

This was at a time when many still regarded electricity with suspicion. Newspapers pushed editions blaring stories of the latest innocent inadvertently fried.

Boston, meanwhile, enjoyed a dubious honor: With over 400,000 people crammed into essentially one square mile downtown, it was the most congested city in the country.

Teams of horses dragged trolley cars through the cramped streets. There were seven streetcar companies, all with varying routes and fares. Getting around town could be a daunting adventure. The downtown area was a hot mess of people, noise and the stench of horse manure. (“Race’s” collection of archival photos is exceptional.)

Businessman Henry Whitney owned several thousand acres in Brookline and saw the potential of connecting his neighborhoods to Boston.

In an acknowledged power grab, he consolidated all seven streetcar companies. Still, that did nothing to check the number of horses (8,400) in the city.

Impressed by Sprague’s work, he pushed the radical idea of an underground subway.

An underground subway was “a breathtaking jump into the unknown,” one talking head says here.

For many, the idea of going underground meant getting closer to the netherworld and you-know-who. More than 12,000 businessmen opposed the plan.

In 1894, by a narrow margin, Bostonians approved plans for building the subway.

When workmen in the Boston Common unearthed over 900 bodies in a Revolutionary War grave site, many took it as a sign from God that man was not meant to travel below the earth.

A March 1897 gas explosion that killed 10 and injured more almost derailed the project.

On Sept. 1, 1897, this hour recounts, with little fanfare, Boston opened its underground subway. City officials were astonished by the turnout.

On the first day, 250,000 people took a ride; in the first year, 50 million.

Sprague was eventually bought out by Edison, who replaced his name on all his inventions. But as “The Race Underground” shows, we have him to thank for our relatively painless ride to work. It’s something to remember the next time you pull out that Charlie Card.