Dante's Divine Comedy will be among the ancient works available online

The Italian government has signed a deal with Google to put the contents of two national libraries on the internet.

Up to one million antiquarian books - including works by Dante, Machiavelli and Galileo - will be scanned and made available free on Google Books.

There is no copyright issue as all the works were published before 1868.

The Italian authorities welcomed the scheme as budget pressures have cut the amount that can be spent on preserving the collections in Rome and Florence.

Mario Resca of the Italian Ministry of Cultural Heritage said the deal would help save the books' content forever, noting that the 1966 Florence flood ruined thousands of books in the city's library.

Previous attempts by Google to scan books have run into legal troubles in the US and France.

A French court ruled that Google had committed copyright violation to the detriment of three publishers by scanning entire books or excerpts and putting them online. Google is appealing the ruling.

And Google had to settle a 2005 class action lawsuit brought by the Authors Guild and Association of American Publishers, which also charged the company with copyright infringement.