Almost an exact contemporary of J. S. Bach, Domenico studied with his father Alessandro, and Gasparini. Domenico's employment took him to royal courts and chapels in Naples (1701), Rome (1709), Lisbon (1720) and Spain (1729). In 1708 Handel met Domenico in Italy and the two traveled together to Rome where Cardinal Ottoboni arranged a friendly competition. With respect to the harpsichord it was ruled that the two were equal, but, on the organ, Domenico quickly acknowledged his rival's superiority. The two remained good friends until Domenico's death. Scarlatti was the first composer to explore the free style of playing the harpsichord (he composed over 600 sonatas for that instrument); in addition, he wrote operas, oratorios, cantatas, and other sacred works.