The fledgling United States Marine Corps proved its dauntless courage with a "miracle" victory in the Battle of Derna on the shores of Tripoli in North Africa on this day in history, April 27, 1805.

The successful attack against overwhelming numbers on the port city in present-day Libya, a stronghold of pirates who spent years attacking United States ships at sea, was the climactic battle of the First Barbary War (1801-05). 

The victory is immortalized in a patriotic American anthem.

ON THIS DAY IN HISTORY, APRIL 26, 1865, JOHN WILKES BOOTH IS KILLED BY UNION TROOPS FOR MURDERING LINCOLN

"From the Halls of Montezuma/To the Shores of Tripoli/We fight our country's battles/In the air, on land and sea," proclaims the rousing opening lyrics of "The Marines' Hymn" (the original 19th-century opening line, pre-air power, was "on the land as on the sea"). 

Writes the Office of the Historian of the U.S. Department of State, "Prior to independence, American colonists had enjoyed the protection of the British Navy." 

US Navy attacks Tripoli

August 1804: Tracers arc in the sky as ships of the U.S. Navy bombard Tripoli in an action against a ruler who supported the Tripolitan (Barbary) pirates. The pirates demanded protection money from all ships and the USA decided to go to war to release their hold on the area.   (MPI/Getty Images)

"However, once the United States declared independence, British diplomats were quick to inform the Barbary States that U.S. ships were open to attack."

The pirates demanded tribute from foreign nations for safe passage through the Mediterranean. 

American ships became a common target, inciting anger among U.S. citizens. 

"From the Halls of Montezuma/To the Shores of Tripoli/We fight our country's battles on the air, on land and sea." — "The Marines' Hymn"

President Thomas Jefferson sent a fleet to the Mediterranean to combat the pirates in 1801. 

Among other indignities, 297 crewmen of the U.S. frigate Philadelphia were captured and taken prisoner after the ship ran aground off Tripoli in 1803.

Derna plaque

The Derna Plaque is part of "Defending the New Republic 1775-1865" display at the National Museum of the Marine Corps in Virginia on May 25, 2010. This plaque was made to honor a battle to take a fort from the Barbary pirates off the northern coast of Africa. The Derna Plaque was discovered 175 years after the battle.  (Tracy A Woodward/The Washington Post via Getty Images)

The Battle of Derna ended with Marines raising the American flag over a captured foreign stronghold for the first time in their history — an act of resolve for which the Corps would later be immortalized in a famous photograph during the Battle of Iwo Jima in World War II.

The victory at Derna forced Barbary pirate leaders to the negotiation table, ending the war two months later with the Treaty of Tripoli. 

GOLD COIN FROM 17TH CENTURY EXPECTED TO FETCH THOUSANDS AT AUCTION AFTER IT WAS INITIALLY THOUGHT A FAKE

The battle followed one of the most incredible efforts in the history of American warfare. 

Marine Corps Lt. Presley O'Bannon, joined by former Army captain and consul William Eaton, led a small band of Marines and an international mercenary force on a 400-mile march from Alexandria, Egypt, to attack the pirate port. 

They were "able to assemble a mixed force of some 400 men, composed of 38 Greek mercenaries, 25 mostly European artillerists, 90 men … 190 camels and their drivers, a small force of Arab cavalry, and eight U.S. Marines," writes the Naval History and Heritage Command in its official report of the battle. 

Gen. William Eaton

American General William Eaton (1764-1811), who took part in the Tripolitan War between the U.S. and the Barbary States. Original Publication: From a drawing, made from an old print, by D McN Stauffer.   (Spencer Arnold Collection/Hulton Archive/Getty Images)

"This force began its march in Egypt on March 8, 1805, and after six weeks of mutiny, hunger, thirst, Arab intransigence and religious tension, arrived on April 25 before Derna, the easternmost fortified town under Tripolitan control."

MEET THE AMERICAN WHO FIRST COMMANDED THE MARINES: REVOLUTIONARY WAR HERO SAMUEL NICHOLAS

The march "with a mercenary army that continued to have serious threats of mutiny, lack of food, and no water was a miracle itself," Kater Miller, a curator for the National Museum of the Marine Corps in Virginia, told Fox News Digital.

Another incredible feat followed.

The 400-mile march "with a mercenary army that continued to have serious threats of mutiny, lack of food, and no water was a miracle itself." — Marine Corps historian Kater Miller 

Derna was defended by a much larger force of 945 cavalry and 1,250 foot soldiers. But the Marine-led assault enjoyed the support of U.S. Navy warships offshore, in one of the first joint-force attacks in U.S. military history. 

Ships from Barbary Wars

1799: A U.S. Navy warship captures an Algerian corsair in the war with Barbary (Tripolitan) pirates. The pirates demanded protection money from all ships and the USA decided to go to war to release their hold on the area.  (MPI/Getty Images)

"Eaton … called on Governor Mustapha Bey to surrender, a summons that was contemptuously rejected," states the Naval History and Heritage Command.

ON THIS DAY IN HISTORY, FEB. 23, 1945, US MARINES RAISE AMERICAN FLAG OVER IWO JIMA, CAPTURED IN HEROIC PHOTO

"Assaulting a fortified coastal city, with a handful of Marines, bolstered by a mercenary army against numerically superior defenders was a tremendous gamble," said Miller. 

The high-stakes gamble yielded big rewards. 

CLICK HERE TO SIGN UP FOR OUR LIFESTYLE NEWSLETTER

The attack deposed longtime Tripolitania dynastic leader Yusuf Karamanliand and led to the Treaty of Tripoli in June. 

Among other outcomes, the crew of the Philadelphia was released.

The attack also earned praise for the Marines from Karamanliand's own brother. 

Barbary War sword

Sword presented to Marine Corps officer Presley O'Bannon to celebrate success in Battle of Derna, on shores of Tripoli, during the Barbary Wars.  (National Museum of the Marine Corps)

"Lieutenant Presley O’ Bannon, commanding the Marines, performed so heroically in the battle that Hamet Karamanli presented him with an elaborately designed sword that now serves as the pattern for the swords carried by Marine officers," Miller said. 

The sword is housed at the National Museum of the Marine Corps in Virginia today. 

CLICK HERE TO GET THE FOX NEWS APP

"The Navy-Marine Corps team worked together to achieve their objective for the first time since the Corps' reconstitution (in 1798)," said Miller. 

"The assault was successful because of intrepid leadership, U.S. Navy support, and tenacity."

For more Lifestyle articles, visit www.foxnews.com/lifestyle.