In the darkness of Theater 9, smoke began to rise. Stephen Barton saw flashes and heard loud pops coming from near a front exit.

Fireworks, he thought at first. Kids playing a prank.

But then he felt the molten buckshot of a shotgun blast pierce his neck and face. His left arm went limp. He collapsed onto the floor in front of his seat as chaos unfolded around him.

As he lay bleeding, Barton heard the sounds of the movie yield to more primal sounds of terror. The screams of the wounded and dying. The desperate pleas of people calling 911. The rattle of gunfire — rhythmic, methodical, endless.

“This might be the end. I might die here,” thought the 22-year-old, who had arrived in Aurora for the first time that afternoon. He decided that he would not die in this place on this night.

“There’s no way it’s going to end here,” Barton kept telling himself. “There’s no way I biked 3,000 miles to come to this theater and get killed in it.”

Forty-four days earlier, on a sun-soaked afternoon in Virginia Beach, Barton and a friend, Ethan Rodriguez-Torrent, had dipped the back wheels of their bicycles into the Atlantic Ocean, posed with a trio of girls in bikinis and started west on a 4,500-mile voyage, bound for San Francisco.

The two had been close since their days at Pomperaug High School in Connecticut. Barton had graduated days earlier from Syracuse University, where he gave the student commencement speech, imploring fellow graduates to “fill your lives with memories as genuine and joyful as those that will be made today.” In the fall, he would head to Russia to teach English on a Fulbright grant.

Rodriguez-Torrent, now between his junior and senior years at Yale University, had first proposed the ride two years earlier. Both men had studied abroad during college — Barton in Spain, Rodriguez-Torrent in Taiwan — and each had found himself stumped by curious foreigners inquiring about the United States.

“They wanted to know how Americans live, what we eat, what we earn, how we celebrate. I discovered pretty quickly I didn’t have very many answers for them,” Rodriguez-Torrent, 22, explained on his blog. “I could speak for my family, or at times on behalf of suburban Connecticut, but rarely did I feel confident talking about anywhere else in America, let alone the country in its entirety. When I got back to the U.S., I started wondering why I had never really thought of exploring America.”

And so they set out to discover the country by pedaling from coast to coast.

They crashed on couches and camped beneath the summer stars. They ate their weight in peanut-butter-and-jelly sandwiches, brownie-flavored Clif bars and turkey-bacon-avocado subs at Subway. They changed countless flat tires, fought off rashes and soreness and mosquitoes. They outran foreboding thunderstorms. They visited old friends.

They biked the misty turns of the Blue Ridge Parkway in Virginia, stopped for roadside barbecue and an antique car show in Kentucky, and caught some live music in Nashville. They dodged logging trucks in Louisiana. They saw Fourth of July fireworks over Longview, Tex., befriended workers at a small-town Chinese buffet and wished a girl named Larkin good luck in the Miss Baca County Princess Pageant.

Barton snapped pictures of the people they met along the way, old and young, boisterous and easy-going. He also posted photo after photo on his Twitter feed of sights they encountered — the sparkling Chesapeake Bay, a golden sunset over the Natchez Trace Parkway in Tennessee, William Faulkner’s home in Mississippi, the endless prairies of Texas, the distant peaks of the Colorado Rockies.

Mile after mile, they saw the best of America. They reveled in its diversity. They welcomed the serendipity of the road. Most of all, they marveled at the generosity that seemed to follow them wherever they went: The man in Dale­ville, Va., who offered a warm shower and the shelter of his back porch. The woman in Glasgow, Ky., who brought them hot chocolate at a campground. The old rancher near Tupelo, Miss., who shook their hands and slipped them $20. The middle-aged diner in Denton, Tex., who spontaneously paid for their dinner at Rooster’s Roadhouse. The man they met at a rural gas station who offered to throw a salsa party in their honor when they made it to Denver.

Before the trip, family members and friends had warned them to keep up their guard, to watch for thieves and madmen, to not rely too wholeheartedly on the benevolence of strangers. “People said to be careful,” Barton recalled. “ ‘The world is a crazy place. There are a lot of crazy people out there.’ ”

Out on the road, in the America they were beginning to know better, crazy seemed far outweighed by kindness. Goodness trumped evil.

* * *

The pair pulled into Aurora on the afternoon of Thursday, July 19, after an 80-mile ride.

Rodriguez-Torrent had a friend named Petra Anderson, an accomplished 22-year-old violinist who had grown up in Aurora and recently graduated from the University of the Pacific in California with a degree in music composition. She had been accepted into a graduate program at the University of Maryland’s music school but was home in Colorado with her mother, who was fighting cancer. She had offered to put the wanderers up at her family’s home for the night.

It was supposed to be a brief pit stop. After all, the majesty of the Rocky Mountains lay ahead, followed by a visit to the Great Salt Lake in Utah, on through the deserts of Nevada, past the neon lights of Reno, across the expanse of the Golden Gate Bridge and on to the finish line of the Pacific.

Rodriguez-Torrent and Barton offered to treat Anderson to the premiere of “The Dark Knight Rises,” a small thanks for her family’s hospitality, and she agreed. As they milled around a Starbucks early that evening, Barton tried to buy tickets on his iPhone without luck. They finally went to the theater and tried to purchase tickets for the 12:01 a.m. showing. It was sold out, so they opted for the 12:05 a.m. show instead.

A buzz already was building at the theater. Hardcore Batman fans had begun to show up hours earlier. It was shaping up as a night of fun, a welcome respite from the road.

On his Twitter feed, Barton posted one last update: ­“#cycletrip goes to the movies @ Century Aurora 16.”

He also attached an Instagram photo. It showed his left hand in a bicycle glove, his fingernails still blackened with grime from the road, clutching his $6.50 ticket to the movie in Theater 9.

* * *

On the floor of the theater, his shirt and pants soaked with blood, Barton heard his traveling partner, Rodriguez-Torrent, call 911 on his cellphone. He heard Anderson scream. She also had been hit by a shotgun blast that would send a pellet through her brain.

The next few minutes were a muddle of gunshots and shouts and smoke, of wondering whether he would live or die. Eventually, Barton peeled himself from the floor and followed a group of people making a push toward a rear exit, deciding it was better to get shot trying to flee than simply sitting still. “I didn’t look back,” he said.

Only later, in the parking lot, did he discover that his friends had also made it out of the theater where 12 people died and scores of others were injured. Rodriguez-Torrent had escaped virtually unharmed. But Anderson had collapsed after stumbling outside, and she was whisked away in an ambulance.

She had emergency surgery, and doctors discovered that the shotgun pellet in her head had traveled through a tiny tube of fluid, a small cavity in her brain that had probably been there since birth. Like a BB through a straw, it apparently carried the pellet through her head without inflicting any serious brain damage. Doctors and friends have said she is walking and talking and expected to make a strong recovery, according to news reports and a Web site set up to aid the family.

Barton also underwent emergency surgery, as doctors cut into his neck and shoulder to remove some shotgun pellets and ensure that they had missed his esophagus, trachea and arteries.

On Monday afternoon, four days after the shooting, Barton left the Medical Center of Aurora with his parents by his side. They grabbed a bite to eat with one of his nurses, then settled in at a hotel off Interstate 225 until the time came to travel back east.

* * *

The next morning, Barton sat in the quiet of his hotel room, wearing a Denver Broncos T-shirt and staring out over the Rocky Mountains that he didn’t get a chance to conquer. The incisions on his neck were swollen and stapled shut. Gunshot wounds dotted his face and chest and arms, and he winced when he moved his left arm and hand. As he spoke, he traced his fingers over the handful of pellets still lodged under his skin. He had counted at least 16 that remained inside him.

He talked about how thankful he felt to have survived, but how he continued to wrestle with why so many others had not. “I’ll struggle with that,” Barton said. “It was so arbitrary, the way people died.”

The way people lived seemed no less arbitrary. Everyone had ended up in that theater based on little more than happenstance. Barton and Rodriguez-Torrent had pedaled into town that very day as part of a grand, idealistic search for the truth about America.

They would finish that journey one day, Barton insisted. Maybe they would come back to Aurora next summer, depart from the theater itself and make their way to San Francisco, raising money along the way for shooting victims and their families. Maybe.

“There are crazy people out there . . . but I think they’re such a microscopic fraction of the people you could meet,” he said. “That’s what this trip has really proven to me. There’s so many people out there waiting to be kind to you, generous to you, in the same way you would be to them. . . . It was very sustained, the kindness we felt from strangers.”