Thanjavur Before the Attack by Venkoji
Following the demise of Chola rule in the 13th century, the Thanjavur area came under the rule of the Pandyas of Madurai. Following the invasion of Madurai by Malik Kafur, the Tanjore also became a part ruled by the Delhi Sultanate. After half a century, Pandya chieftains reasserted their independence. Soon afterwards, they were conquered by the Vijayanagar Empire and Thanjavur became part of the Empire. The supremacy of Vijayanagar was challenged by the Nayaks of Madurai (who were also part of Vijayanagara empire only for a long time). Madurai Nayaks eventually conquered Thanjavur in 1646. The rule of the Thanjavur Nayaks lasted until 1673. In 1973, Chokkanatha Nayak the ruler of Madurai invaded Thanjavur and killed the ruler Vijayaraghava (a fight among people belonging to the same origins).
Chokkanatha placed his brother Alagiri on the throne of Thanjavur, but within a year, Alagiri declared himself independent. Chokkanatha recognised the independence of Thanjavur.
Attack by Venkoji
A son of Vijaya Raghava approached the Bijapur Sultan and asked him to help him get back the Thanjavur throne. In 1675, the Sultan of Bijapur sent a force commanded by the Maratha general Venkoji (half brother of Shivaji) to recapture the kingdom from the new invader. Venkoji defeated Alagiri, and occupied Thanjavur. He declared himself as king of Thanjavur. Thus began the rule of the Marathas over Thanjavur. Venkoji ruled till 1684. During his reign, his brother Shivaji invaded Gingee and Thanjavur in 1676–1677. During the last years of his reign, Venkoji allied with Chokkanatha of Madurai and repulsed an invasion from Mysore..
Shahuji I was the eldest son of Venkoji and became king at the age of twelve. Mughals attacked Tiruchirapalli and forced Shahuji I to pay tribute. Shahuji was known as a patron of literature. During his reign, he fought battles with the Raja of Madurai and Ramnad due to disputes for border lands.
Serfoji I was a younger son of Venkoji and he ruled from 1712 to 1728. His rule also was marked by regular warfare and disputes with the Madurai Nayak.
Tukkoji, a younger brother of Serfoji I ruled Thanjavur from 1728 to 1736. He defended the invasion of Chanda Sahib and repulsed a Muhammedan invasion.
A period of anarchy followed the death of Tukkoji which came to an end when Pratapsingh succeeded to the throne in 1739. He ruled up to 1763. He allied with Muhammad Ali, the Nawab of the Carnatic. He aided the British against the French. In 1762, a tripartite treaty was signed between Thanjavur, Carnatic and the British by which he became a vassal of the Nawab of the Carnatic.
Thuljaji was the last independent ruler of Thanjavur. In 1773, Thanjavur was annexed by the Nawab of the Carnatic who ruled till 1776. The throne was restored to Thuliaji by the Directors of the British East India Company. But he lost his independence and came under control of Company administration.
Thuljaji was succeeded by his teenage son Serfoji in 1787. Soon afterwards, he was deposed by his uncle and regent Amarsingh. But, Serfoji II recovered the throne in 1798 through his negotiations with the British, and he handed over the reins of the kingdom to the British East India Company, becoming part of the Tanjore District (Madras Presidency). The district collectorate system was installed to collect the revenues, do pubic works and manage judicial work. Serfoji II had the control of the Fort and the surrounding areas. He reigned till 1832. His reign is noted for the literary, scientific and technological accomplishments of the Tanjore country.
Shivaji II was the last Maratha ruler of Thanjavur and reigned from 1832 to 1855. He did not have any male heirs, After his death, the Queen adopted her nephew. The British did not accept this adoption and Thanjavur was annexed by them as per the provisions of the Doctrine of Lapse.
The Thanjavur Maratha Rajas favoured Sanskrit and Telugu, the earlier popular languages of the area. Most of the plays were performed in Sanskrit. Venkoji, the first ruler of the Bhonsle dynasty composed a 'Dvipada' Ramayana in Telugu. His son Shahuji was a great patron of learning and of literature. Most of the Thanjavur Maratha literature is from his period. Advaita Kirtana is one of the prominent works from this period. Serfoji II built the Saraswathi Mahal Library within the precincts of the palace to house his enormous book and manuscript collection. Apart from Indian languages, Serfoji II was proficient in English, French, Dutch, Greek and Latin as well.