"Greece and Spain are prepared to accept asylum seekers who are in future identified by German authorities at the German-Austrian border and who have a Eurodac registration in those countries," the German government said in a statement, referring to the EU asylum fingerprint database.
The agreements were made at a crunch EU summit in Brussels dominated by the migration issue.
They come as Merkel faces a threat by her hardline Interior Minister Horst Seehofer that unless she reaches EU deals allowing the return of many asylum seekers, he will shutter German borders to them by early July.
New Spanish Prime Minister Pedro Sanchez acknowledged that Merkel's difficulties at home had helped focus minds in Brussels.
"We sympathise with the situation Germany is going through at the moment," he told reporters. "Chancellor Merkel was grateful for this gesture of solidarity."
Asked whether she thought the accords with Athens and Madrid met Seehofer's ultimatum requirements, Merkel told reporters in Brussels that she believed they even surpassed them.
"They are more than equivalent in their effect," she said.
Seehofer is head of Christian Social Union, the Bavarian sister party of Merkel's Christian Democrats. Any move toward closing the border between Bavaria and Austria would force Merkel to sack Seehofer and likely end the parties' seven-decade alliance.
This has raised the spectre of an implosion of Merkel's uneasy coalition government just 100 days after it took office, potentially ending the German leader's 12-year tenure in power.
The German government said it would in the next four weeks clarify details of the agreements with Spain and Greece, whose implementation would then be "regularly assessed".