MILAN, May 1 (Reuters) - Mediaset and Vivendi are moving closer to signing an agreement that would end years of legal sparring stemming from a failed pay-TV deal in 2016, sources close to the matter said.

Lawyers for the two sides are at work through the weekend on the fineprint of a possible accord, three sources said.

The Italian broadcaster and its second biggest shareholder have come close in the past to settling the multiple legal disputes but have been unable to finalise negotiations.

One source said that an accord appeared more within reach this time around. Vivendi, Mediaset and its top shareholder Fininvest all declined to comment.

The latest push comes after a Milan court earlier this month dismissed a 3 billion euro ($3.6 billion) damage request from Mediaset, which is controlled by the family of former Prime Minister Silvio Berlusconi, against Vivendi.

The court ordered Vivendi to pay only around 1.7 million euros after the French media group ditched an accord to buy Mediaset's pay-TV business and then built a 29% stake which the Milanese broadcaster considers illegitimate.

Vivendi has scored other court victories, regaining full voting rights on its stake and the group controlled by French financier Vincent Bollore is now in a position to block extraordinary shareholder resolutions at Mediaset.

Mediaset on Monday said it had revived a plan to move its legal base to the Netherlands to pursue European alliances and wished to develop this strategy with the backing of all its shareholders.

Bets on a possible accord lifted shares in Mediaset to a 17-month high this week.

The sources said discussions were continuing and an accord appeared close. One source said its terms would likely include Vivendi progressively cutting its Mediaset stake.

Daily la Repubblica reported on Saturday that Vivendi could also pay "a few dozens million euros" as compensation to settle all pending lawsuits.

The paper said Vivendi could sell over five years two thirds of its stake, the portion it had been forced to place in an arms-length trust, with Fininvest reserving the right of first refusal. ($1 = 0.8321 euros) (Reporting by Elvira Polilina, writing by Valentina Za, editing by Angus MacSwan)