In 1802 Macdonough served on the Constellation (the same ship his brother James served on) to help fight in the first Barbary War against the Tripolitan pirates. In 1803 he was assigned to the USS Philadelphia (38 guns) so they could capture Tripolitan ships like the Mirboka. Then the Philadelphia got captured by the Tripolitan pirates when it ran aground. Then Macdonough volunteered to help Stephen Decatur sneak on the Philadelphia and burn it so the Tripolitan pirates could not use it. After he helped in the burning of the Philadelphia he was promoted to lieutenant. After he was promoted he went on to help find the murderer of James Decatur and they found out that the murderer was a Tripolitan captain when James did not let the Tripolitan pirates on his ship when they captured it.