"Part of my political life is coming to an end. I am leaving the Socialist Party, or the Socialist Party is leaving me," the 54-year-old told RTL radio.
Valls said he would now be part of the presidential "majority" in the National Assembly led by Macron's Republic on the Move (REM), although the party has ruled out the possibility of Valls taking a leading role.
Valls, who was prime minister under Socialist president Francois Hollande from 2014 to 2016, was rejected by Socialist voters in the party's primary to choose a candidate for this year's presidential election.
Macron's 14-month-old won a commanding majority in the legislative election that followed, completing the president's transformation of the French political landscape.
More From This Section
The Socialists were humiliated, losing over 200 seats after five years in power overshadowed by sluggish economic growth and high unemployment.
Valls said Tuesday he felt "sad and bitter... At what the PS has become".
He had approached REM about running for the party in the legislative election but was rebuffed.
The pugnacious, Spanish-born Valls was Macron's boss when the now-president was economy minister and a fierce rivalry developed between them over his presidential ambitions.
Valls oversaw Hollande's attempt to liberalise economic policy and his decision to ram through reforms of the labour market without a parliamentary vote were deeply unpopular with the left of the party.
The labour reforms sparked months of street protests last year.
Government spokesman Christophe Castaner said his decision to leave the Socialists was "not a surprise".
Castaner said Valls would not have "a top role -- he doesn't want one and the new generation of Republic on the Move would not welcome it".
A parliamentary source said that while Valls would not be an REM lawmaker, he would enjoy the status that such a role would bring, such as having speaking time in debates.