A judge on Thursday urged stock market regulators and Tesla CEO Elon Musk to amicably settle their dispute over his tweets.

If not, she said she'll decide whether to grant regulators' request that the outspoken executive face escalating fines if he breaks rules protecting investors.

U.S. District Judge Alison J. Nathan asked how she should punish Musk if she finds him in contempt for violating a deal with the Securities and Exchange Commission requiring him to first clear with lawyers tweets that might disclose important company facts.

SEC attorney Cheryl Crumpton recommended fines.

But at the end of the hearing, Nathan ordered both sides to seek a resolution over the next two weeks.

"Everybody take a deep breath, put your reasonableness pants on and work this out," Nathan said.

Even so, Nathan said court-supervised agreements must be obeyed.

"I don't care if you are a small potato or a big fish," Nathan said as Musk, with an estimated worth of $22 billion, sat at a defense table with his lawyers.

Nathan pressed Crumpton during the hearing to define the conditions under which Musk should seek approval before he tweets, and drew attention to ambiguity surrounding the rules the SEC sought to enforce.

Musk, who followed the back-and-forth intently with a slight frown and furrowed brow, emerged from the courtroom to say: "I'm very happy with the result and I'm impressed with Judge Nathan's analysis."

Legal experts said it makes sense for the two sides to negotiate another settlement rather than to leave the decision to Nathan, although they cautioned it's always difficult to predict what the famously mercurial Musk will do.

"The big question is whether he will dig in his heels and resist," said Peter Henning, a Wayne State University law professor and former SEC attorney. "I get the feeling they will come up with something because Musk probably doesn't want to risk being held in contempt of court. That will be like two strikes against him."

Attorney John Hueston, representing Musk, told the judge the SEC had failed to show his client had violated the deal. He said his client was "somebody trying his best to comply."

"He actually does what he is told," Hueston said.

In a statement after the hearing, Musk signaled he is willing to work out a deal with regulators. "We have always felt that we should be able to work through any disagreements directly with the SEC, rather than prematurely rushing to court," he said.

The issue over Musk's tweets stems from a settlement reached last year after Musk tweeted that he had secured the funding to take Tesla private at $420 a share — a substantial premium over the price at the time — when he did not. That tweet, last August, sent the company's stock on a wild ride. The SEC says it hurt investors who bought Tesla stock after the tweet but before they had accurate information.

Musk later backed off the idea of taking the company private, but regulators concluded he had not lined up the money to pull off the deal.

The SEC says Musk blatantly violated the settlement in February when he tweeted about Tesla's vehicle production without a lawyer's approval.

Musk's 13-word tweet on Feb. 19 said Tesla would produce around 500,000 vehicles this year. But the tweet wasn't approved by Tesla's "disclosure counsel," and the SEC's contempt-of-court motion filed that month said Musk had not sought a lawyer's approval for a single tweet.

Musk said his tweet about car production didn't need pre-approval because it wasn't new information that would be meaningful to investors. His attorneys said the SEC was violating his First Amendment rights to free speech.

Much of the debate Thursday centered around whether the SEC rules provide a clear way to for Musk to determine whether or not the information he's about to tweet would be material to investors and, therefore, require preapproval from lawyers.

"This case is like a shot across the bow from the SEC," said Marc Leaf, a New York lawyer who formerly worked for the agency and advised on its settlement agreements. "What they would like Tesla's board to do is tell Elon, 'You are a genius but your tweets aren't the smartest thing to be doing, so cut it out.'"

But Hueston argued further restricting Musk's ability to communicate about his company and imposing fines would "freeze his ability" to operate as an effective entrepreneur.

To support his arguments, Hueston cited an earlier exchange between the judge and Crumpton in which Nathan said she was "surprised" that the SEC left it up to Musk in so many instances whether to run by his lawyers what he intended to put out publicly.

"Does he need preapproval?" the judge asked Crumpton at one point.

"We're not saying 'yes' or 'no,'" she responded.

Hueston said the SEC's first step after the tweet about production should have been to approach Tesla in good faith, and Nathan agreed.

"The parties should be meeting, conferring and providing some clarity so this issue won't happen again," Hueston said.

The SEC says its deal doesn't restrict Musk's freedom of speech because as long as his statements are not false or misleading, they would be approved.

Meanwhile, Tesla's shares fell 8% Thursday after the company disclosed that both its car manufacturing pace and vehicle delivery rate slowed during the first three months of the year, raising questions about its ability to be consistently profitable.

The SEC sought to oust Musk from his role as chairman and CEO over his August tweet. Instead, Musk and Tesla agreed to pay $40 million and made other concessions to settle the case and ensure Musk remained CEO.

Musk's unpredictable behavior has led some to question whether he should remain in that job, while others say he's a visionary too valuable to lose. Last year, Musk berated stock market analysts for asking questions about Tesla's finances and prompted a defamation lawsuit when he called a diver who helped rescue 12 boys on a Thai soccer team from a flooded cave a pedophile.