If Union Gen. George Gordon Meade had had his way, the battle that changed the course of the Civil War would have taken place on Maryland soil.

A fight in a Pennsylvania crossroads town called Gettysburg wasn't in his plans for July 1, 1863. Nor was the Confederate commander, Robert E. Lee, looking for a fight that day and in that place. But the chance encounter of a Confederate unit in search of supples and Union cavalry on patrol foiled Meade's plans to set a trap for Lee in Carroll County.

What might have gone down in history as the Battle of Taneytown — or the Battle of Big Pipe Creek — never happened. Instead the three-day battle took place about 15 miles up the road and across the state line. It would end in a Confederate defeat, after Lee's attempt to storm Union-held Cemetery Ridge ended in the bloody repulse of Pickett's Charge.

A century and a half later, the Battle of Gettysburg still grips the imagination of scholars and ordinary Americans. Over the next week, an estimated 200,000 people are expected to jam the area for dozens of events that commemorate the battle. That includes a ceremony Sunday, followed by a procession to the national cemetery established after the battle.

Adam Goodheart, a historian at Washington College in Chestertown, said the story of Gettysburg — particularly Pickett's Charge — continues to resonate with Northerners and Southerners alike. "That moment becomes the war in miniature — that here there were gallant Confederates who were brave but ultimately serving a lost cause, hurling themselves against Union forces that would turn out to be unconquerable."

Goodheart, author of "1861: The Civil War Awakening," does not buy that interpretation, which became popular in the decades of national reconciliation after the war. In his view, Union victory in the war was hard-won and far from inevitable. And Gettysburg, he said, is overestimated as a turning point.

Nevertheless, it was the bloodiest clash of armies ever to take place in North America. While it ended in Northern victory, there were points when the Union teetered on the edge of catastrophe.

While the epic battle was fought in Pennsylvania, Maryland played a central role in the campaign. It was through Maryland that Lee invaded — hoping to undermine political support for the Lincoln administration by dealing the Union a defeat in the North — and it was through the state that he retreated. More than any other Civil War battle, it was a fight that pitted Marylander against Marylander — particularly at Culp's Hill, site of the Maryland monument honoring soldiers who fought on both sides.

In some ways, however, it's the role Maryland almost played that is most fascinating.

On June 30, 1863, Meade was preparing a strong Union position just south of the Mason-Dixon line. The new commander of the Army of the Potomac planned to position his troops south of Big Pipe Creek to intercept Lee's Army of Northern Virginia if it struck en route to Washington or Baltimore. Early on July 1, he assigned his corps commanders positions along that line.

"Meade wanted to fight in Maryland," said Allen C. Guelzo, a Gettysburg College historian who this year published "Gettysburg: The Last Invasion," a well-received account of the campaign. The creek line and bluffs on the south side of the creek provided an easilly defended position, he said.

The position Meade chose was better than the one his army found at Gettysburg, according to Ronald A. Church, a Carroll County amateur historian who has written about the Pipe Creek Line. Meade's plan also would have made it difficult for Lee to escape in a retreat, he said.

Church, a retired county public works official, led a reporter on a tour of the planned 20-mile line, which would have stretched from Middleburg in the west to Manchester in the east. Some points along the line look much as they would have in 1863, he said, except that much more of the land would have been cleared of trees — allowing lookouts on the heights to spot a Confederate advance.

The line also blocked all three of the roads Lee could have used to march on Baltimore or Washington from Gettysburg, Church said. It offered excellent supply lines by road and rail as well as the flexibility to shift units along the line to meet points of attack.

"If Meade's plan had come to fruition, this would have been the Cemetery Ridge of Taneytown," Church said.

The Pipe Creek Line would become a historical footnote rather than a major battlefield, largely because of the actions of Union Gen. John Reynolds, a Pennsylvanian eager to defend his state from the Confederate invaders. He disregarded Meade's wishes and pushed his 1st Corps to Gettysburg, where on July 1 it came to the support of Union cavalry that collided with an advancing Confederate division.

Reynolds lost his life that morning but got his fight. Once the battle was joined, Guelzo said, Meade could not back down. It was the residents of Gettysburg rather than Taneytown who would hide in their cellars as the battled raged.

Over three bloody, sweltering days, the Union and Confederate armies pounded each other at a series of then-obscure places whose names are now synonymous with hallowed ground: Devil's Den, Little Round Top, Cemetery Hill, Culp's Hill.

On the second day of the battle, the Rebels came close several times to crashing through Union lines and delivering what might have been a war-ending blow to the Lincoln administration. But each time, a countercharge blunted the Confederate attack.

On July 3, Lee overplayed his hand by ordering Gen. George Pickett's assault, which failed amid horrific casualties. There was a brief Confederate breakthrough, but it was quickly sealed up, and the surviving Southerners staggered back to their lines in defeat.