Valls on Wednesday joined Defence Minister Jean-Yves Le Drian in backing Macron, who served as economy minister in his government but was never a party member.
Pointing to opinion polls that show National Front leader Marine Le Pen going through to May's second round of the presidential election, he said he would vote Macron in the 23 April first round so as to "take no risks for the republic".
Rejection of primary result
But on Wednesday morning he told the BFMTV channel, "The higher interests of the country, the higher interests of France, takes precedence over the rules of a party, a primary or a committee."
Macron told Europe 1 radio that the former prime minister's backing would not stop him being the "guarantor of a renewal of faces, a renewal of practices" and his spokesperson, Laurence Haïm indicated that he would not invite Valls back to the premier's post.
Hamon backers furious
The news will have come as no surprise to Hamon, who has fallen to fifth place in the polls behind the hard left's Jean-Luc Mélenchon and seen a number of the Socialist Party's right wing come out for his centrist rival.
Ahead of Valls's announcement he described the defections as a "soap opera" intended to undermine him.
"At a moment when democracy is in danger, when we can see that a big anti-democratic party, the National Front, could take power, not respecting the decision of the ballot box is a problem," he told France 2 TV.
His supporters took it personally.
"Everybody now knows what a commitment signed by a man like Manuel Valls means - nothing. What a man without honour means," former economy minister Arnaud de Montebourg declared.
One of Hamon's campaign organisers, Mathieu Hanotin, described the move as a "despicable attempt at sabotage", and Socialist MP Karine Berger also dubbed it "despicable".
Valls has history with Hamon ... and Macron
Hostility between Valls and Hamon predates the Socialist primary.
Not that Valls has always got on well with Macron, either.
Their relations while in government were described as "execrable" and he described Macron's announcement of candidacy as a "non-event".
Right wing mocks Socialists
On the French right, Bertrand Accoyer, the general secretary of the Republicans whose candidate François Fillon has his own problems, sneered at the Socialist Party's "total decomposition", while Le Pen tried to use it to discredit her principal rival.
"I am struck by the indecency of the political class in respect to democracy," she commented. "On the one side and on the other we see contempt for the results of the primaries, which at the time were presented as the acme of democratic life."
Valls's backing showed that Macron would have to rely on a majority of the former government's supporters in parliament, she said.