The former treasurer of Rajoy's Popular Party, Luis Bárcenas, said he handed €25,000 ($33,000) in 500-euro notes to the prime minister in March 2010, said sources present in the hearing, who asked not to be named.
Bárcenas was answering questions by a judge at Spain's High Court in a scandal that has rocked the government.
He handed to the court papers detailing the slush fund and "declared that he was the author of the documents" published in newspapers which showed secret payments to Rajoy in the 1990s and 2000s, one of the sources told reporters.
Another source who attended the hearing said Bárcenas confirmed that the money came from a secret fund, implying that the payments were undeclared.
"He said the whole party leadership received envelopes" of undeclared cash, the source said.
Rajoy, in power since late 2011, ruled out resigning over the scandal, in which he has denied any wrongdoing.
Bárcenas is currently jailed pending investigations into a separate corruption affair implicating senior members of the party.