It was an unlikely marriage.
In one corner: bicyclists with a passion for spontaneous acts of silliness, who have made an annual tradition of an unsanctioned midnight ride along the Boston Marathon route.
And in the other: commuter rail officials — governed by rules and schedules and routines — who were unpleasantly surprised last year when 600 revelers showed up with bicycles at South Station, hoping to take the last outbound train to the starting line.
But, contrary to the spirit of spontaneity, the bicyclists and train officials have come to a surprising compact: For the first time, the Massachusetts Bay Commuter Railroad will provide a train to take 700 cyclists to the starting line the night before the Boston Marathon for the Midnight Marathon.
Started four years ago, the ride has ballooned in popularity, with hordes of participants drawn by Marathon fever, the novelty of biking the region’s busy streets without heavy car traffic, and a general appreciation for doing weird things just because.
But in recent years, commuter rail officials had struggled to accommodate the hundreds who showed up to the last outbound Worcester train on an otherwise-quiet Sunday night. A cyclists-only train, they hope, will better allow them to handle the riders.
“I know the group organizers like to do things a little spontaneously,’’ said Gillian Wood, chief customer service officer for the commuter rail. “But it’s very hard to deal with 600 or 700 bicyclists on a train spontaneously.’’
The tickets will cost $15, almost double the normal price, and go on sale Monday at South Station. The train will depart at 10 p.m. April 14, the Sunday night before the race, and make a nonstop trip to Southborough, a short bike ride from Hopkinton, where the race begins.
Rhiannon D’Angelo, spokeswoman for the commuter rail, said the increased cost of the tickets will cover the costs of the extra train.
The Midnight Marathon tradition started in 2009 with Greg Hum, a recent Boston University graduate who came up with “a totally ad-hoc, spur-of-the-moment idea,’’ he said: Ride the Marathon route in the middle of the night, when most cars are off the streets, after the barrage of signs and banners appear, but before roads officially close early in the morning.
Hum recruited a few of his friends, and over the years, word spread, reaching Boston SOS — alternately known as the Societies of Spontaneity or a Society of Shenanigans. The group’s leaders, responsible for the an annual no-pants subway ride on the T, thought the impromptu bike ride was right up their alley.
“We wanted to find like-minded compadres,’’ said James Cobalt, founder and director of the group.
The absurdity, Hum said, has been key to the event’s popularity.
“It’s become this kind of crazy communal experience,’’ Hum said.
“Biking in traffic is stressful,’’ he continued. “It’s a very different kind of surreal serene experience when you’re biking the city at midnight. You feel more connected to Boston.’’
Last year, event organizers alerted commuter rail administrators before the race, telling them that 300 people would likely show up with bicycles. Instead, double that number appeared, bicycles in tow, expecting to take the last train out.
“At around 10 o’clock,’’ Wood recalled, “it was pretty obvious we weren’t going to get everyone on the train.’’
Commuter rail staff scrambled to bring an extra train from the railyard to accommodate the extra passengers and bicycles.
This year, event organizers met with the commuter rail months ahead of time, hoping to find a better solution. They feared the commuter rail would bar the group from using the trains to transport their bikes to the starting line, Hum said. A Red Sox game scheduled the same day added to concerns about space. And some of the cyclists’ fellow passengers last year were unimpressed with the gush of rowdy, adrenaline-infused revelers, Cobalt said.
“We went into this meeting last week bracing ourselves for no Marathon ride,’’ Hum said.
Instead, the commuter rail proposed a cyclists-only train, with a higher price and a capped number of tickets. That way, Wood said, the rail could be sure it had space and staff.
“We’re very regimented. We like rules and regulations and plans,’’ Wood said. “To be able to plan for it this year was what we wanted to do.’’
The commuter rail also asked for 25 volunteers to help load and unload the bicycles.
Some participants find their way to the starting line without help from public transit, as about 100 did last year. Hubway waived fees for cyclists who used the bike-share program to complete the 26.2 miles, which they may do again this year.
Hum stressed that completing the ride did not require a top-tier level of fitness.
“Biking the Marathon is like a jog in the park,’’ Hum said. “You don’t have to stress yourself out like the Marathon runners do, and you can still feel like you’re a part of it.’’
Similar premarathon bike rides take place in other parts of the country: Last month, hours before the Los Angeles Marathon 3,000 cyclists rode their own race, which was not-quite-legal but permitted by police who escorted the pack.
Even with commuter rail’s blessing, organizers said, they’re not worried about damaging a rebellious street creed.
“There are walks for this and rides for that,’’ Cobalt said. “And this is something we do simply because it’s awesome.’’