As set out here, it began during a time of increasing trade between southeast Asia, Europe and the United States. In 1831, American merchant ships were visiting exotic ports as they engaged in the pepper trade. One port was Quallah Battoo (a/k/a Kuala Batu). One such ship was the merchant vessel Friendship:
Various small trading boats darted back and forth along the coast trading pepper with the merchant ships waiting offshore. On February 7, 1831 the captain of the Friendship went ashore to purchase some pepper from the natives when three boats attacked his ship, massacred the crew, and plundered its cargo. Endicott and a handful of his crew fled to another port with the assistance of a friendly native chief named Po Adam. There they enlisted the help of three other merchant captains. With their help Endicott managed to retake his ship and sailed back to Salem, Massachusetts. Upon reaching Salem there was a general uproar about the massacre and President Andrew Jackson dispatched the frigate USS Potomac under Commodore John Downes to punish the natives for their treachery.An interesting description of Jackson's foray into Asia is available here in which a comparison is made to the Global War on Terror.
Downes arrived off Sumatra and took action:
The public were unanimous in calling for a redress of the unparalleled outrage on the lives and property of citizens of the United States. The government immediately adopted measures to punish so outrageous an act of piracy by despatching the frigate Potomac, Commodore Downs, Commander. The Potomac sailed from New York the 24th of August, 1831, after touching at Rio Janeiro and the Cape of Good Hope. She anchored off Quallah Battoo in February 1832, disguised as a Danish ship, and came to in merchantman style, a few men being sent aloft, dressed in red and blue flannel shirts, and one sail being clewed up and furled at a time. A reconnoitering party were sent on shore disguised as pepper dealers, but they returned without being able to ascertain the situations of the forts. The ship now presented a busy scene; it was determined to commence an attack upon the town the next morning, and every necessary preparation was accordingly made, muskets were cleaned, cartridge-boxes buckled on, cutlasses examined and put in order, &c.A book detailing the voyage of Potomac is available here. This book Cruise of the United States Ship Potomac Around the World is interesting for its details of what has been called the "first US military intervention in Asia" - though not it is not necessarily viewed as a tempered response to a pirate attack on a merchant ship (although the source of the comment needs to be considered):
At twelve o'clock at night, all hands were called, those assigned to take part in the expedition were mustered, when Lieut. Shubrick, the commander of the detachment, gave them special orders; when they entered the boats and proceeded to the shore, where they effected a landing near the dawn of day, amid a heavy surf, about a mile and a half to the north of the town, undiscovered by the enemy, and without any serious accident having befallen them, though several of the party were thoroughly drenched by the beating of the surf, and some of their ammunition was injured.
The troops then formed and took up their line of march against the enemy, over a beach of deep and heavy sand. They had not proceeded far before they were discovered by a native at a distance, who ran at full speed to give the alarm. A rapid march soon brought them up with the first fort, when a division of men, under the command of Lieut. Hoff, was detached from the main body, and ordered to surround it. The first fort was found difficult of access, in consequence of a deep hedge of thorn-bushes and brambles with which it was environed. The assault was commenced by the pioneers, with their crows and axes, breaking down the gates and forcing a passage. This was attended with some difficulty, and gave the enemy time for preparation. They raised their warwhoop, and resisted most manfully, fighting with spears, sabres, and muskets. They had also a few brass pieces in the fort, but they managed them with so little skill as to produce no effect, for the balls uniformly whizzed over the heads of our men. The resistance of the Malays was in vain, the fort was stormed, and soon carried; not, however, till almost every individual in it was slain. Po Mahomet, a chief of much distinction, and who was one of the principal persons concerned in the outrage on the Friendship was here slain; the mother of Chadoolah, another rajah, was also slain here; another woman fell at this port, but her rank was not ascertained; she fought with the spirit of a desperado. A seaman had just scaled one of the ramparts, when he was severely wounded by a blow received from a weapon in her hands, but her life paid the forfeit of her daring, for she was immediately transfixed by a bayonet in the hands of the person whom she had so severely injured. His head was wounded by a javelin, his thumb nearly cut off by a sabre, and a ball was shot through his hat.
Lieutenants Edson and Ferret proceeded to the rear of the town, and made a bold attack upon that fort, which, after a spirited resistance on the part of the Malays, surrendered. Both officers and marines here narrowly escaped with their lives. One of the natives in the fort had trained his piece in such a manner as to rake their whole body, when he was shot down by a marine while in the very act of applying a match to it. The cannon was afterwards found to have been filled with bullets. This fort, like the former, was environed with thick jungle, and great difficulty had been experienced in entering it. The engagement had now become general, and the alarm universal. Men, women and children were seen flying in every direction, carrying the few articles they were able to seize in the moments of peril, and some of the men were cut down in the flight. Several of the enemy's proas, filled with people, were severely raked by a brisk fire from the six pounder, as they were sailing up the river to the south of the town, and numbers of the natives were killed. The third and most formidable fort was now attacked, and it proved the most formidable, and the co-operation of the several divisions was required for its reduction; but so spirited was the fire poured into it that it was soon obliged to yield, and the next moment the American colors were seen triumphantly waving over its battlements. The greater part of the town was reduced to ashes. The bazaar, the principal place of merchandize, and most of the private dwellings were consumed by fire. The triumph had now been completed over the Malays; ample satisfaction had been taken for their outrages committed upon our own countrymen, and the bugle sounded the return of the ship's forces; and the embarkation was soon after effected. The action had continued about two hours and a half, and was gallantly sustained both by officers and men, from its commencement to its close. The loss on the part of the Malays was near a hundred killed, while of the Americans only two lost their lives. Among the spoils were a Chinese gong, a Koran, taken at Mahomet's fort, and several pieces of rich gold cloth. Many of the men came off richly laden with spoils which they had taken from the enemy, such as rajah's scarfs, gold and silver chunam boxes, chains, ear rings and finger rings, anklets and bracelets, and a variety of shawls, krisses richly hilted and with gold scabbards, and a variety of other ornaments. Money to a considerable amount was brought off. That nothing should be left undone to have an indelible impression on the minds of these people, of the power of the United States to inflict punishment for aggressions committed on her commerce, in seas however distant, the ship was got underway the following morning, and brought to, with a spring on her cable, within less than a mile of the shore, when the larboard side was brought to bear nearly upon the site of the town. The object of the Commodore, in this movement, was not to open an indiscriminate or destructive fire upon the town and inhabitants of Quallah Battoo, but to show them the irresistible power of thirty-two pound shot, and to reduce the fort of Tuca de Lama, which could not be reached on account of the jungle and stream of water, on the morning before, and from which a fire had been opened and continued during the embarkation of the troops on their return to the ship. The fort was very soon deserted, while the shot was cutting it to pieces, and tearing up whole cocoa-trees by the roots. In the afternoon a boat came off from the shore, bearing a flag of truce to the Commodore, beseeching him, in all the practised forms of submission of the east, that he would grant them peace, and cease to fire his big guns. Hostilities now ceased, and the Commodore informed them that the objects of his government in sending him to their shores had now been consummated in the punishment of the guilty, who had committed their piracies on the Friendship. Thus ended the intercourse with Quallah Battoo. The Potomac proceeded from this place to China, and from thence to the Pacific Ocean; after looking to the interests of the American commerce in those parts she arrived at Boston in 1834, after a three years' absence.
The first US military intervention in Asia took place in 1832. The year before, some Sumatrans temporarily seized an American merchant vessel, looting it and killing three of its sailors. The captain of the vessel has claimed that those responsible were drug addicts attracted to the ship's 12 chests of opium; but historians note that there was strong evidence that the seizure was brought about by US merchants cheating the Indonesians. In any event, Washington dispatched a naval vessel, whose captain, without bothering to find out the facts of the incident, set the town of Kuala Batu on fire after plundering it, and slaughtered somewhere between 60 and upwards of 150 people, including non-combatants.Historian Arthur M. Schlesinger, Jr, also cites the operation as an example of The Imperial Presidency (he also considered Jefferson's dispatch of ship to take on the Barbary pirates as such). To his credit, Schlesinger notes that research on occasions of the President ordering military action most often involve action against non-governmental entities taken to protect American citizens (p.52). Such might have been the case with Kuala Batu, except that Schlesinger finds Commodore Downes exceeded the instructions given to him by the President and the Secretary of the Navy.
Downes's actions when they became known, provoked a mini-uproar about what instructions he had received, with Jackson, in essence, being forced to defend acts that he seems to have disagreed with. Downes was not promoted further.
However the United States government may have viewed Downes's assault on the pirate community, it did not stop further attacks by Malay pirates on U.S. ships and further military action was required. There were underlying matters of international intrigue being played out, as is noted here, but the injection of a British steam powered warships seems to have slowed piracy down substantially. The same author notes that the attack on Kuala Batu did not earn the same level of fame as the attacks in Tripoli against those Barbary pirates, though the Marines have offered up it up as part of their proud history:
Daring death and danger is an old story to the U. S. Marines, who have landed on foreign soil at least 200 times on errands for Uncle Sam.History, after all, is usually written by the victors...
They claim to have unfurled their flag "to every breeze from dawn to setting sun," and that is no idle boast. Often their landings were accompanied by enough thrills to last a lifetime.
Such a landing was made at Quallah Battoo in Sumatra in 1832 for the purpose of bringing to terms some Malay pirates who had robbed an American ship and murdered some of the crew.
Three Forces Formed--In the early morning a landing party of bluejackets and marines rowed ashore and, dividing their forces into three parties, one group attacked the first stronghold, blowing up the stockade gate and meeting the Malays in hand-to-hand conflict. The enemy fought to the death.
One by one three other fortresses were captured during the five hours of bitter fighting required to bring the natives to terms. The affair ended when a delegation of native chiefs made a plea for peace.
You might be interested in this rendition of Malay pirates, which is part of a larger work on pirates of by-gone times.
Red blob on map is general area of Kuala Batu.