The regiment was recruited from across the Commonwealth of Pennsylvania during the early fall of 1862, with companies raised from the following counties:
The 151st Pennsylvania was formed and mustered into nine months' Federal service at Camp Curtin on the outskirts of the state capital at Harrisburg. On November 4, 1862, the company commanders met to elect regimental officers from among themselves. Harrison Allen, former major of the 10th Pennsylvania Reserve Regiment and captain of Company F, was elected colonel of the regiment. George F. McFarland of Company D was elected lieutenant colonel. John W. Young of Company C was elected major. On November 26, the regiment was issued its equipment and smoothbore muskets, and sent by train to Washington, D.C.
After a halt of a few days in Washington, the 151st Pennsylvania received orders to fall in under the New York brigade of Col. Frederick George D'Utassy. D'Utassy's brigade was composed of the 39th, 111th, 125th, and 126th New York. On December 3, the 151st Pennsylvania and the four New York regiments marched away from Washington toward Union Mills, Virginia on the outer perimeter of Washington's defenses. Posted along Bull Run near the Bull Run battlefield, the regiment stood picket duty and guarded against the partisan guerrillas of Confederate Col. John S. Mosby.
On February 10, the regiment received orders to march to the main winter quarters of the Army of the Potomac at Belle Plain, Virginia. There, the regiment was reassigned and brigaded with the 121st Pennsylvania, 142nd Pennsylvania, and 80th New York under the command of Brigadier General Thomas Rowley. Rowley's brigade was the First Brigade of Maj. Gen. Abner Doubleday's Third Division of the Maj. Gen. John F. Reynolds' I Corps.
The 151st Pennsylvania's first engagements were during the Chancellorsville Campaign in late April and early May, 1863 near Fredericksburg, Virginia. The Army of the Potomac, under the command of Maj. Gen. Joseph Hooker, made a series of diversions to mask a bold flanking maneuver around the left flank of Gen. Robert E. Lee's Army of Northern Virginia. The I Corps acted as one of the diversions, remaining across the Rappahannock River from Fredericksburg and acting as a pinning force against Lee. While fulfilling this purpose on April 30, the 151st Pennsylvania had its first experience with enemy fire. Confederate artillery batteries across the river opened a strong bombardment in the area. The shelling caused some men of the untested 151st to break ranks and run for cover, but Col. Allen reported later the shells "fell with great rapidity, but none of my command were injured."
On May 2, as the main body of the army engaged Lee's troops in the tangled second-growth forest known as The Wilderness, the I Corps marched roughly twenty miles to join the army's lines. Late that afternoon, Confederate Lt. Gen Thomas ″Stonewall″ Jackson led his corps on a bold flanking maneuver and crushed the Federal right. When the I Corps arrived around midnight, it moved to bolster the right and anchored the army's flank on the Rapidan River. The 151st Pennsylvania was posted abutting the river and was tasked with guarding the main Federal supply and retreat route at United States Ford. The I Corps remained mostly unengaged for the remainder of the battle, however the 151st Pennsylvania worked in conjunction with the nearby 12th Massachusetts to fight off a series of small incursions by Brig. Gen. Francis T. Nicholls' Louisiana brigade of Jackson's corps. Though the 151st Pennsylvania sustained slight casualties through these skirmishes, Col. Allen reported 12 of the enemy killed and 61 taken prisoner. For the entirety of the campaign, Allen reported 1 man killed, 1 officer "(accidentally)" and 5 men wounded, and 9 men missing.
As General Robert E. Lee and his Army of Northern Virginia commenced their invasion of Pennsylvania in June, 1863, the 151st Pennsylvania and the Army of the Potomac likewise moved north to repel them. As the campaign began, the regiment was struggling through an epidemic of typhoid fever and dysentery, leaving over 100 men and over half the regiment's officers too ill for duty. On June 8, Col. Allen was granted a furlough due to illness, and Lt. Col. McFarland assumed command of the regiment.
By June 30, the armies had begun to converge on the crossroads town of Gettysburg, Pennsylvania near the Mason–Dixon line. That night, the 151st Pennsylvania crossed the border into Pennsylvania and encamped with the rest of Maj. Gen. Abner Doubleday's division along the banks of Marsh Creek roughly six miles southwest of town. Shortly after dawn the on July 1, Union Brig. Gen. John Buford's division of cavalry engaged the advancing Confederate division of Maj. Gen. Henry Heth on the series of low ridges northwest of town. Becoming heavily outnumbered, Buford called for assistance from any nearby infantry. Maj. Gen. John F. Reynolds, commanding the I Corps and camped a half mile down the road from the 151st Pennsylvania, answered the call and immediately ordered his corps to march to the sound of the fighting. Shortly before 8:00 AM, the 151st Pennsylvania received orders to fall in and begin marching. The 151st and the three other regiments of Brig. Gen. Thomas A. Rowley's brigade followed local roads north and arrived at the scene of the fighting shortly before 11:00 AM. As the regiment marched toward the area, they witnessed their corps commander Maj. Gen. Reynolds being carried to the rear on a stretcher, killed by a bullet to the head. One man recorded later, "Many a tear fell at the site of the stretcher."
Upon arriving at the Federal lines, the regiment was sent to remain in reserve on Seminary Ridge, the ridge closest to town and named for the Lutheran Theological Seminary that stood there. While placed near the Seminary, the 151st and other units began constructing crude breastworks in case the area should be needed as a defensive fall-back point. At roughly 3:00 PM, the regiment - by now the last reserve of the I Corps - was ordered forward into a gap that had formed in the main Federal line on McPherson's Ridge. McPherson's Ridge runs parallel to Seminary Ridge and is separated by low hollow about 300 yards wide.
The regiment advanced from Seminary Ridge, across the hollow, to McPherson's Ridge. Quickly forming their line on the ridge just in front of a woodlot named Herbst Woods, the regiment was immediately struck by a volley from Confederate troops in the trees. Urging his men to fire slowly and aim carefully, Lt. Col. McFarland ordered the regiment to fire at will. McFarland recalled of the firing discipline, "This was strictly observed, and during the next hour's terrific fighting, many of the enemy were brought low."
The Iron Brigade, one of the first Federal infantry units engaged that morning, was positioned in McPherson's Woods not far to the north of the 151st Pennsylvania's right flank. The regiments of the Iron Brigade mistakenly believed the large nine-month regiment to be a brigade coming to their relief, and thus began to withdraw to Seminary Ridge. On the right of the 151st Pennsylvania, the other regiments of Rowley's brigade had held position for a period of time in the fields west of Gettysburg. However, these regiments became outflanked on their left by the North Carolinians of Brig. Gen. James Pettigrew's brigade. Its supporting forces on the right and left both gone, the 151st Pennsylvania was soon entirely alone on McPherson's Ridge. The regiment had sustained heavy casualties from its front and its exposed left from Pettigrew's North Carolina troops. Seeing the regiment's vulnerable position, Lt. Col. McFarland ordered his remaining men to conduct a steady retreat back across the hollow to the Seminary, where other I Corps regiments were rallying and digging in for the next wave of Confederate attacks.
A short break in the fighting occurred as Lt. Gen. A. P. Hill rotated in a fresh division to carry on the attacks on the Federal lines near Gettysburg. The 151st Pennsylvania ensconced itself in the barricade before the Seminary, along with the 4th U.S. Light Artillery, Battery B and infantry of Rowley's brigade and the Iron Brigade. The Confederate division of Maj. Gen. William Dorsey Pender advanced toward Seminary Ridge and renewed the assault on the breaking Federal lines. The 151st Pennsylvania faced the South Carolina brigade of Col. Abner Perrin. The regiment attempted to repulse the enemy, but the Federal line again became outflanked from the left. Unbeknownst to the men of the 151st Pennsylvania, Federal troops to the left had begun retreating through town to the high ground at Cemetery Hill. Receiving heavy fire from the left, Lt. Col. McFarland ordered a final retreat to the heights south of town. A thick layer of smoke reduced visibility and prevented McFarland from watching Confederate movements. While crouching in an attempt to see below the smoke as he guided his men away, McFarland was struck simultaneously by bullets through both lower legs. Private Lyman Wilson of Co. F attempted to carry McFarland back to the Seminary for treatment, as it was then being used as a hospital. As McFarland's arm was around Wilson's neck, a bullet came close enough to Wilson's head that it sheared a button off McFarland's cuff. McFarland was treated inside the building, and once Confederate troops advanced and took possession of the town, fell captive to the enemy.
The regiment reformed on Cemetery Hill at the southeastern edge of town with 113 officers and men left, with Capt. Walter L. Owens of Company D assuming command. It was assigned a position on the left of the II Corps, where on July 3, it helped repulse Pickett's Charge. During the battle, the regiment lost 367 out of 478 officers and men killed, wounded, and captured, a casualty rate of nearly 75%. Col. Allen arrived at the close of the fighting to re-assume command of the regiment, which then participated in the pursuit of the Confederate army. Following the conclusion of the campaign, it was sent to Harrisburg on the 19th and mustered out on the 27th.
Maj. Gen. Abner Doubleday said of the regiment:
At Gettysburg, they won, under the brave M'Farland, an imperishable fame. They defended the left front of the First Corps against vastly superior numbers; covered its retreat against the overwhelming masses of the enemy at the Seminary, west of the town, and enabled me, by their determined resistance, to withdraw the corps in comparative safety. This was on the first day. In the crowning charge of the third day of the battle, the shattered remnants of the One Hundred and Fifty-first Pennsylvania, with the Twentieth New York State Militia [alternate name of 80th New York], flung themselves upon the front of the rebel column, and drove it from the shelter of a slashing in which it had taken shelter from a flank attack of the Vermont troops. I can never forget the services rendered me by this regiment, directed by the gallantry and genius of M'Farland. I believe they saved the First Corps, and were among the chief instruments to save the Army of the Potomac, and the country from unimaginable disaster.— Abner Doubleday
A plaque in McAlisterville, Pennsylvania stands across the street from the site of the former McAlisterville Academy where Lt. Col. McFarland and other members of the regiment taught prior to their enlistment. The plaque memorializes the regiment and its actions at Gettysburg.
The regiment's national colors are kept and preserved by the Pennsylvania Capitol Preservation Committee in Harrisburg, along with the flags of other Pennsylvania Civil War regiments. The colors are currently on loan to Gettysburg National Military Park and can be viewed at the park museum and visitor center.