When he was 12 he was sent to Rome, where he may have studied with Carissimi. He married in 1678 and later that year was appointed "maestro di cappella" of San Giacomo degli Incurabili (now 'in Augusta'). By then he had already composed at least one opera (the title is unknown and it was not performed) and a second, "Gli equivoci nel sembiante", was a resounding success in 1679. It confirmed Scarlatti in his chosen career as an opera composer and attracted the attention of Queen Christina of Sweden, who made him her "maestro di cappella".
In 1684 Scarlatti was appointed "maestro di cappella" at the vice-regal court of Naples, at the same time as his brother Francesco was made first violinist. It was alleged that they owed their appointments to the intrigues of one of their sisters (apparently Melchiorra) with two court officials, who were dismissed. For the next two decades over half the new operas given at Naples were by Scarlatti. Two of them, "Il Pirro e Demetrio" (1694) and "La caduta dei Decemviri" (1697), were especially successful, but by 1700 the War of the Spanish Succession was beginning to undermine the privileged status of the Neapolitan nobility, rendering Scarlatti's position insecure. In 1702 he left with his family for Florence, where he hoped to find employment for himself and his son Domenico with Prince Ferdinando de' Medici.
When these hopes failed, Scarlatti accepted the inferior position in Rome of assistant music director at San Maria Maggiore. With a papal ban on public opera, he found an outlet for his talents in oratorio and in writing cantatas for his Roman patrons, notably Prince Ruspoli and the cardinals Ottoboni and Pamphili. In 1706 he was elected to the Arcadian Academy, with Pasquini and Corelli. The following year he attempted to conquer Venice, the citadel of Italian opera, with "Mitridate Eupatore" and "Il trionfo della libertà", but they both failed and Scarlatti was forced to return to Rome, where he was promoted to the senior post at San Maria Maggiore.
Scarlatti found little satisfaction in the life of a church musician, and towards the end of 1708 he accepted an invitation from the new Austrian viceroy to resume his position at Naples. He remained there for the rest of his life, but maintained close contacts with his Roman patrons and made several visits there, some of them of long duration. It was probably in 1715 that he received a patent of nobility from Pope Clement XI. His final opera, "La Griselda", was written for Rome in 1721, and he seems to have spent his last years in Naples in semi-retirement. Quantz visited him in 1724 and Hasse was his pupil for a time.
Scarlatti's reputation as the founder of the Neapolitan school of 18th-century opera has been exaggerated. He was not influential or even very active as a teacher, nor was he the sole originator of the musical structures (da capo aria, Italian overture, accompanied recitative) with which his name is associated, though he did bring to these a level of skill and originality which surpassed those of his contemporaries. Some of his best music is in the chamber cantatas, too few of which are known today.