WARSAW — Poland’s national archive said Thursday that the country’s legendary anticommunist leader Lech Walesa had in his early years been a spy for communist secret police, in an official confirmation of the existence of documents that has been suspected for decades.

The Institute for National Remembrance, a state archive that stores sensitive files from Poland’s recent past, said documents including Walesa’s handwritten agreement from the 1970s to collaborate with secret police had d been found.