"Try this one," the manager of the cigar factory said. "It's grown from Cuban seed." We inspected the offering, and shook our heads at the price. It was the first day of our attempt to traverse Mexico by mountain bike, and this little cigar workshop was an unlikely detour. We'd pedaled only 20 miles when we were lured in.

"These are more economical," the manager told us, pointing to another stash. "They're also very big." We nodded in agreement, and Walter Bishop, the leader of our nine-member crew, pulled out his wallet. "We'll celebrate with these when we reach the Pacific," he promised – not that we needed the extra incentive.

I'd done 10 bike trips in Mexico – many of them with Walter – and every time I looked at a map I thought, I've got to ride across. A transcontinental ride is, in fact, an iconic challenge for cyclists: The journey always has a distinct start and finish line: the oceans. And in North America, the only continent besides Australia where nations stretch from coast to coast, such traverses have taken on great symbolism.

Mexico offers some advantages for the cross-country cyclist: a vast number of undeveloped backwoods roads, and a shape – narrow at the bottom, wide at the top – that makes the trip a relatively low-mileage affair. We'd be able to do the 400 miles – hopefully all on dirt – in about seven days. The most direct route is from Veracruz, on the Gulf Coast, into the Sierra Madre, through Oaxaca's capital, and down to the surfing hot spot of Puerto Escondido, on the Pacific. But several tourists had been attacked by banditos in northern Oaxaca in recent months, so Walter – a 56-year-old Mexican David Crosby look-alike who's been cycling his home country for more than 20 years – suggested a more circular route: Ride south along the Veracruz coast, then inland to an abandoned railbed that runs south parallel to a highway to the west coast oil-refining town of Salina Cruz.

After packing away our cigars, our two strongest riders, Edgar and Mike, spinning instructors from the Mexican city of Durango, took off. The other five of us – all friends of Walter and all experienced cyclists – tried to keep up. I was riding with Choco, a 30-year-old dentist, also from Durango, and Tim, my buddy from Wisconsin (the only other gringo besides me). Miguel, a graphic designer, tagged behind with Walter, followed by a support van and driver.

Despite the sag wagon, this wasn't your typical bike tour: There would be no gourmet meals or satiny bed sheets. We would camp out and eat at roadside stands after pedaling a solid 50 miles a day. My only real concern was dehydration, which had incapacitated me on my last Mexico bike trip. Continuing south from the cigar factory, we pedaled through reedy terrain, rolling into thick rain forest. By the end of the first day we'd reached the town of Tlacotalpan, tucked into the delta of the Papaloapan River. The locals were setting up for a feast; the church was decked in colorful ribbons and images of saints. "Is it a religious festival?" I asked.

Walter looked around. Small stalls lined the town square, centered around a mechanical bull. "Now, yes," he said. "But by midnight, it's gonna be pretty pagan."

Godlessness arrived in a one-liter Pepsi bottle served by a kindly lady who had repurposed her fabric shop as a bar for the fete. The bottles, about a dollar each, were filled with "coco toro" – half coconut milk and half cane alcohol. In the town square locals were challenging both the mechanical bull and a person wearing a bull costume made of wire and Christmas lights, laced with bottle rockets and Roman candles. A day of bike riding and a liter of poison had significantly diminished my reflexes, and I inadvertently put myself in the direct line of fire. A sparkling projectile glanced off my leg. Luckily, I was well anesthetized.

When we awoke the next morning I felt surprisingly fresh. We wound into the sharply rising Sierra de los Tuxtlas mountain range, passing ancient volcanic craters and ridges of hardened igneous rock. Then we veered inland, toward the crossroads city of Acayucan. From there we would hit Highway 185, the two-lane thoroughfare that parallels the old railbed.

Our first big climb came just after we turned west. We huffed our way into the Tuxtlas, passing Lake Catemaco, the biggest of a series of crater lakes. The afternoon temperature soared into the 90s, and we had a killer 2,000-foot ascent ahead of us. Every few miles a tiny tienda, where local families earned extra pesos by selling Coke and sangria-flavored soda pop, beckoned.

When we finally topped the Tuxtlas the middle of Mexico stretched out before us, oscillating toward what looked like a fixed horizon – an exhilarating view well worth our hard work. We picked our way back down on dirt trails and on the trackbed. It was a long day of riding: 68 overheated miles of gravel, dirt, and – to our chagrin – tarmac, in several spots where the tracks were impassable. The key to riding the tropics is to skip the middle of the day. But since we had limited time, that was impossible. As a Southern Californian, I'm used to high temperatures, and the following morning I pushed off energetically. Despite downing several bottles of water, however, I quickly got sluggish. I'd stopped sweating – I had heat exhaustion.

"Maybe you should ride in the van," Walter suggested. No way. Continuing might make me sicker – even endanger my health – but you can't claim a cross-country ride if you sit out even a single mile. The entire trip would be ruined if I didn't keep riding.

Within a mile Walter and Miguel had vanished. In the two hours since we'd left Nuevos Morelos I'd covered less than five miles. After struggling through another painful mile I found the group relaxing at an open-air restaurant.

I collapsed in a hammock at the back of the concrete building and fell asleep. By the time I reopened my eyes the sun had sunk to the west and everyone but Walter was gone. Mosquitoes buzzed around me, and trucks rumbled by. I immediately knew I was fine, like when a fever breaks. I pedaled ahead and saw our group halted. It was a drug checkpoint. I'd always been told not to make eye contact with soldiers, but Walter was engaged in friendly conversation. "They'll let us camp here," he said.

We pitched tents and listened to south-of-the border gangsta music, chronicling the exploits of cocainistas, coming from the barracks. As we cooked dinner on a discada (a woklike pan made from a farmer's combine), the setting seemed perfect.

At this point we were three-quarters of the way to the coast. We had 100 mostly paved miles to go – two days' riding. The mountains that run down the center of Mexico rose in front of us – the Continental Divide is an obstacle no matter what part of North America you're crossing. The climbs would be huge, but then it would be downhill all the way.

We made it almost to the coast before the wind kicked in, stopping us in our tracks in the city of Salina Cruz. We found a restaurant and sat down for dinner of traditional Oaxacan food – a surprisingly delicious paste made of grasshoppers and peppers smeared onto tortillas. That's when Walter came up with an idea that should have sounded ludicrous to us. "Let's go back inland, to Oaxaca City," he said. "Then turn around and ride over the Sierra again all the way to Puerto Escondido on dirt." He was suggesting that we backtrack half the distance we'd come. But not one of us batted an eye. After spending too much of the trip dodging cars, the chance to get on dirt trails was irresistible. What had been up to this point a high-speed race to the finish line now had the potential to become the ride of a lifetime. The cigars would have to wait.

The next morning we hightailed it to Oaxaca in the van, and from there the map showed just 75 miles between us and the Pacific. We pedaled west on the Camino Real, used for centuries by Indians, conquistadors, and modern travelers alike as the main byway of the isthmus. The unpaved road was barely wide enough for a car, and we frequently had to pick our way around farmers and livestock. Scrubby agave and creosote gradually gave way to forest.

Throughout the day we climbed and dropped. On descents we hit speeds nearing 50 mph, overtaking buses and trucks. On climbs the same vehicles clattered by us.

We turned onto a dirt road that cuts north through a town called Juquila. "One of the most sacred shrines in Mexico is there," Walter had said. He arrived first and found an abandoned chicken coop where we could spread our sleeping bags.

The next morning a group of local children draped our bikes with flowers. They tied thick green stems and white blooms to our handlebars. "Peregrinacion ciclista," the girls said. Bicycle pilgrimage.

Juquila's holy status comes from a two-centuries-old wooden likeness of Mary. Penitents began arriving from all over Mexico, seeking a manda, or favor – a cure for a sick mother, help with a drinking problem, the return of an errant spouse. Religious wayfarers come to Juquila by foot or bike.

As we climbed to the peak overlooking the town we were joined by a dozen riders. One warned us about the sharp descent into the town.

Halfway down I found Choco on the ground, lifting himself from the asphalt, covered in bloody scrapes. His helmet was cracked in half. "A dog," he explained. We hustled him into the van with a case of road rash that warranted a trip to the hospital. For a moment a sense of gloom settled over us. But the pilgrims kept passing. Whole families, shuffling, many on their knees. We had no right to feel downtrodden.

The hospital was next to the start of the 30-mile dirt road that drops 8,000 feet to the Pacific. With Choco recuperating in the van after receiving treatment, the rest of us descended through alpine glades, picking our way around oversize boulders. I counted 35 switchbacks before I lost track. My hands began to ache. There were hours to go.

This was the day I'd fantasized about. We'd had a tragedy – Choco's crash – and moments of beauty – the pilgrims. And now the riding itself was dreamlike.

We descended through mist, then dust. As we got lower, creek crossings became more frequent. Red dirt stuck to our legs. Soon our entire bodies were caked. Edgar and I skidded through wide turns and angled around narrow ones. Every time we hit a rise we'd attack, fly over the crest, and pedal through the landings.

Neither Edgar nor I spoke during the last 20 miles. We were in the rain forest, getting closer to the sea. We could tell by the thicker air, the smell – bromeliads, orchids – and the frenzied parrots and macaws flying overhead. It was close to sunset. Edgar and I crossed a rise and saw it: a glowing Pemex sign against the reddening sky. The coastal highway. Just seven-tenths of a mile to go. Sprint! I gained a bike length on Edgar, but at the last moment he pulled alongside me and we finished together at the edge of the Pacific. I've biked in nearly every country in this hemisphere. This was the best descent I'd ever pedaled.

The following morning we rode two hours along the coast to Puerto Escondido, our final destination, stopping at a few marshy overlooks to search for crocodiles. We camped at a decrepit trailer park and joined the town's permanent party. We had an epic trip to celebrate, after all. I spent most of the evening attempting to charm a young woman who operated a hot dog stand adjacent to the campsite. She asked where we'd come from. I told her, and I explained that I had wanted to do this trip for years. She looked at me as if I were a madman. "No way," she said. "Nobody rides their bike across Mexico." She was right. Nobody does. But we had. And now we had our cigars to smoke.

Plan Your Own Mexican Invasion

You'll need maps by INEGI (bicimapas.com.mx) and a guide like Walter Bishop (from $100 per day; 52-618-825-8891; aventurapantera.com.mx).