Terms of the agreement were not disclosed.
But a statement issued by Michael Sands, spokesman for Federline's lawyer, said, "The parties signed an agreement which was a global settlement on all issues of their marriage and child custody."
The couple have two sons together, 18-month-old Sean Preston and 6-month-old Jayden James.
Celebrity Web site TMZ.com quoted unnamed sources as saying that Federline, who has tried to launch a new career as a singer, will receive $1 million as part of the settlement and that the couple agreed to joint custody of their boys.
A source close to the couple told Reuters the $1 million figure was inaccurate but declined to say how much it really was.
The agreement, which is subject to final approval of a judge, was signed after a five-hour meeting between the couple and their lawyers Thursday in Los Angeles, Sands said.
Sands said a breakthrough in the talks came after Federline, 29, stepped away to smoke a cigarette and Spears followed him outside. They had a 15-minute private conversation, then returned to the negotiating table, he said.
Spears, 25, who left a rehabilitation center last week after a month of treatment for undisclosed issues, filed for divorce from Federline in November.
The two married in September 2004, just eight months after she had wed a former high school sweetheart in Las Vegas in a spur-of-the-moment union that was quickly annulled.
Since her split last year from Federline, who has two children by a former girlfriend, Spears has made headlines for increasingly erratic behavior.
She checked into the Malibu treatment center on February 21 after shaving off her hair at a Los Angeles beauty salon.
The exact reasons for entering rehab were not made clear, but she was photographed making her way to Alcoholics Anonymous meetings outside the center during her stay there.
According to TMZ.com, Spears returned to the Hollywood club scene Thursday night after her settlement with Federline, paying a 30-minute visit to the Bridge Restaurant and Lounge.
Spears' singing career has remained virtually dormant since her marriage to Federline. She shot to fame as a teenager in 1999 and sold an estimated 70 million records. Her last album of new material, "In the Zone," was released in 2003.