Kevin Federline Gives Britney Spears an Ultimatum

Britney Spears caused a case of mass whiplash when she bolted from rehab after less than 24 hours – then checked back in days later. The reason for the quick turnaround? An ultimatum from Kevin Federline, a source tells PEOPLE.

Upset by the news that Spears had checked out of Promises in Malibu on Wednesday, Federline and lawyer Mark Vincent Kaplan scheduled an emergency hearing to seek physical and legal custody of their sons Sean Preston, 18 months, and Jayden James, 6 months, says a source.

Ultimately, Federline, 28, gave his estranged wife a choice: Either she got back into Promises that night or Federline would go to court in the morning, says the source.

(Spears, 25, had since January had custody of the boys, with visitation for Federline, thanks to a temporary court order issued after she filed for divorce in November.)

At about 7 p.m. that night, Spears, driven by a friend, showed up outside Federline's home in Tarzana, Calif. – followed by some 20 paparazzi. Federline failed to appear, so she left.

When a photographer followed her to a gas station, she became enraged and began whacking his SUV with an umbrella. Later that night Spears's mother, Lynne, 51, who had flown in from her home in Kentwood, La., to be near her daughter and grandsons, took Spears back to Promises. Says a friend of Federline's: "Britney scared everyone real bad."

On Friday Federline – who, sources say, also played a role in persuading Spears to enter rehab in the first place – spent an hour visiting his ex at Promises; the next evening he also brought the boys, and they were joined by Lynne.

"Kevin is working closely with Lynne to let Britney know how serious it is that she gets help," says one family friend. A source close to Federline notes that "Kevin loves Britney ... nothing has changed about that."

Right now the boys are "being taken care of by Kevin," says a source. "Lynne is helping." Eventually, says a Spears family friend, Federline, who will turn 29 this month, "would like [Britney] to have the kids because he thinks she is a good mother."

But to make that happen will require hard work. A typical stay at Promises lasts 45 days – and Spears "is getting no special treatment," says her manager Larry Rudolph. "She has a regular room, a regular routine. She is doing exceptionally well."

To find out who's hoping Britney and Kevin will get back together, what new scandal Britney will face when she gets out of rehab and more, pick up the new issue of PEOPLE, on newsstands Friday.