Undercover NYPD officers infiltrated protest groups by attending their secret meetings in the months leading up to the 2004 Republican National Convention – and warned that cops could be attacked with marbles and urine, once-confidential documents released yesterday reveal.

A federal judge ordered the 600 pages of documents unsealed following a lengthy court battle challenging the legitimacy of many of the 1,800 arrests made during the four-day convention at Madison Square Garden.

The NYPD reports analyze protest groups and their potential to cause trouble.

In one report, the NYPD warned that protesters were poised to fire water guns filled with urine or pepper spray and to spread marbles and oil on the streets “to cause responding foot, motorcycle and mounted units to. . . fall.”

The documents also show that the NYPD sought to monitor activists living in other states and Europe, covertly using the Internet to chat with them.

“I think a close examination of those documents will show the NYPD did an outstanding job of protecting the city during the convention,” Police Commissioner Ray Kelly said.

Some 10,000 cops were deployed during the convention to protect the city from terrorist threats and cope with thousands of demonstrators, whose protests turned out to be largely peaceful.