linguistic:paraphrasing, structural:expansion
Kapellmeister years

Haydn's job title under Count Morzin was Kapellmeister, that is, music director. He led the count's small orchestra in Unterlukawitz and wrote his first symphonies for this ensemble – perhaps numbering in the double figures. Philip Downs comments of these first symphonies: "the seeds of the future are there, his works already exhibit a richness and profusion of material, and a disciplined yet varied expression." In 1760, with the security of a Kapellmeister position, Haydn married. His wife was the former Maria Anna Theresia Keller (1729–1800), the sister of Therese (b. 1733), with whom Haydn had previously been in love. Haydn and his wife had a completely unhappy marriage, from which time permitted no escape. They produced no children, and both took lovers.

Count Morzin soon suffered financial reverses that forced him to dismiss his musical establishment, but Haydn was quickly offered a similar job (1761) by Prince Paul Anton, head of the immensely wealthy Esterházy family. Haydn's job title was only Vice-Kapellmeister, but he was immediately placed in charge of most of the Esterházy musical establishment, with the old Kapellmeister Gregor Werner retaining authority only for church music. When Werner died in 1766, Haydn was elevated to full Kapellmeister.

As a "house officer" in the Esterházy establishment, Haydn wore livery and followed the family as they moved among their various palaces, most importantly the family's ancestral seat Schloss Esterházy in Eisenstadt and later on Esterháza, a grand new palace built in rural Hungary in the 1760s. Haydn had a huge range of responsibilities, including composition, running the orchestra, playing chamber music for and with his patrons, and eventually the mounting of operatic productions. Despite this backbreaking workload, the job was in artistic terms a superb opportunity for Haydn. The Esterházy princes (Paul Anton, then from 1762 to 1790 Nikolaus I) were musical connoisseurs who appreciated his work and gave him daily access to his own small orchestra. During the nearly thirty years that Haydn worked at the Esterházy court, he produced a flood of compositions, and his musical style continued to develop.

Much of Haydn's activity at the time followed the musical taste of his patron Prince Nikolaus. In about 1765, the prince obtained and began to learn to play the baryton, an uncommon musical instrument similar to the bass viol, but with a set of plucked sympathetic strings. Haydn was commanded to provide music for the prince to play, and over the next ten years produced about 200 works for this instrument in various ensembles, the most notable of which are the 126 baryton trios. Around 1775, the prince abandoned the baryton and took up a new hobby: opera productions, previously a sporadic event for special occasions, became the focus of musical life at court, and the opera theater the prince had built at Esterháza came to host a major season, with multiple productions each year. Haydn served as company director, recruiting and training the singers and preparing and leading the performances. He wrote several of the operas performed and wrote substitution arias to insert into the operas of other composers.

1779 was a watershed year for Haydn, as his contract was renegotiated: whereas previously all his compositions were the property of the Esterházy family, he now was permitted to write for others and sell his work to publishers. Haydn soon shifted his emphasis in composition to reflect this (fewer operas, and more quartets and symphonies) and he negotiated with multiple publishers, both Austrian and foreign. His new employment contract "acted as a catalyst in the next stage in Haydn's career, the achievement of international popularity. By 1790 Haydn was in the paradoxical position... of being Europe's leading composer, but someone who spent his time as a duty-bound Kapellmeister in a remote palace in the Hungarian countryside." The new publication campaign resulted in the composition of a great number of new string quartets (the six-quartet sets of Op. 33, 50, 54/55, and 64). Haydn also composed in response to commissions from abroad: the Paris symphonies (1785–1786) and the original orchestral version of The Seven Last Words of Christ (1786), a commission from Cádiz, Spain.

The remoteness of Eszterháza, which was farther from Vienna than Eisenstadt, led Haydn gradually to feel more isolated and lonely. He longed to visit Vienna because of his friendships there. Of these, a particularly important one was with Maria Anna von Genzinger (1754–1793), the wife of Prince Nikolaus's personal physician in Vienna, who began a close, platonic relationship with the composer in 1789. Haydn wrote to Mrs. Genzinger often, expressing his loneliness at Esterháza and his happiness for the few occasions on which he was able to visit her in Vienna. Later on, Haydn wrote to her frequently from London. Her premature death in 1793 was a blow to Haydn, and his F minor variations for piano, Hob. XVII:6, may have been written in response to her death.

Another friend in Vienna was Wolfgang Amadeus Mozart, whom Haydn had met sometime around 1784. According to later testimony by Michael Kelly and others, the two composers occasionally played in string quartets with Carl Ditters von Dittersdorf (second violin) and Johann Baptist Wanhal (cello) for small gatherings attended by Giovanni Paisiello and Giovanni Battista Casti. Impressed by Mozart's work, Haydn praised it unstintingly to others. Mozart returned the esteem in his "Haydn" quartets. In 1785 Haydn was admitted to the same Masonic lodge as Mozart, the " Zur wahren Eintracht " in Vienna.