Facebook Inc. and Alphabet Inc.’s Google agreed to “cooperate and assist one another” if they ever faced an investigation into their pact to work together in online advertising, according to an unredacted version of a lawsuit filed by 10 states against Google last week.

The suit, as filed, cites internal company documents that were heavily redacted. The Wall Street Journal reviewed part of a recent draft version of the suit without redactions, which elaborated on findings and allegations in the court documents.

Ten Republican attorneys general, led by Texas, are alleging that the two companies cut a deal in September 2018 in which Facebook agreed not to compete with Google’s online advertising tools in return for special treatment when it used them.

Google used language from “Star Wars” as a code name for the deal, according to the lawsuit, which redacted the actual name. The draft version of the suit says it was known as “Jedi Blue.”

The lawsuit itself said Google and Facebook were aware that their agreement could trigger antitrust investigations and discussed how to deal with them, in a passage that is followed by significant redactions.

The draft version spells out some of the contract’s provisions, which state that the companies will “cooperate and assist each other in responding to any Antitrust Action” and “promptly and fully inform the Other Party of any Governmental Communication Related to the Agreement.”

In the companies’ contract, “the word [REDACTED] is mentioned no fewer than 20 times,” the lawsuit says. The unredacted draft fills in the word: Antitrust.

A Google spokesperson said such agreements over antitrust threats are extremely common.

The states’ “claims are inaccurate. We don’t manipulate the auction,” the spokesperson said, adding that the deal wasn’t secret and that Facebook participates in other ad auctions. “There’s nothing exclusive about [Facebook’s] involvement and they don’t receive data that is not similarly made available to other buyers.”

The redacted lawsuit filed last week makes no mention of Facebook Chief Operating Officer Sheryl Sandberg. According to the draft version, Ms. Sandberg signed the deal with Google. The draft version also cites an email where she told CEO Mark Zuckerberg and other executives: “This is a big deal strategically.”

Like Google, Facebook has also disputed the allegations in the lawsuit, saying its agreements for bidding on advertising promote choice and create clear benefits for advertisers, publishers and small businesses.

“Any allegation that this harms competition or any suggestion of misconduct on the part of Facebook is baseless,” a Facebook spokesperson said.

The final version of the lawsuit didn’t make public details about the deal’s value. The draft states that starting in the deal’s fourth year, Facebook is locked into spending a minimum of $500 million annually in Google-run ad auctions. “Facebook is to win a fixed percent of those auctions,” the draft version says. The lawsuit says “Facebook is to [REDACTED].”

According to the draft version, an internal Facebook document described the deal as “relatively cheap” when compared with direct competition, while a Google presentation said if the company couldn’t “avoid competing with” Facebook, it would collaborate to “build a moat.” The redacted lawsuit filed last week doesn’t include those quotes.

The lawsuit alleges that Google executives worried ahead of the deal about competition from Facebook as well as others deploying “header bidding,” a technique for buying and selling online ads.

In an internal Google presentation from October 2016, an employee expressed concern about the potential for competition from Facebook and other big tech companies, saying, “to stop these guys from doing HB [header bidding] we probably need to consider something more aggressive,” according to the draft.

The redacted lawsuit discusses Google’s concerns about competition and mentions the presentation, but it doesn’t include the quote.

According to an internal Google communication from November 2017 discussing a potential “Facebook Partnership” for Google’s “Top Partner Council,” Google said that its endgame was to “collaborate when necessary to maintain status quo…” The redacted lawsuit describes a presentation about Google’s endgame, but doesn’t include the quotes.

As the two sides neared agreement, according to the draft, Facebook’s negotiating team sent an email to Mr. Zuckerberg, saying the company faced options: “invest hundreds more engineers” and spend billions of dollars to lock up inventory, exit the business, or do the deal with Google. Mr. Zuckerberg wanted to meet before making a decision, according to the draft.

Those details don’t appear in the lawsuit filed last week, which only names Mr. Zuckerberg once, in a separate paragraph about another internal communication about the deal.

For years, criticism of Google’s online advertising empire has focused on how the company leveraged its powerful consumer-facing platforms, such as Google Search and YouTube, to take over another lucrative but less visible business: the software that acts as a middleman for buying and selling ads across the web.

The Facebook allegations add a new wrinkle—that Google cut a deal with a competing middleman, one that the states describe as Google’s “largest potential competitive threat.”

They also represent a potent legal risk. Under U.S. law, agreements to fix prices can be easier to prove than the states’ other accusations—namely that Google is maintaining an illegal monopoly.

In addition to the suit filed in Texas, Google was hit last week in a separate antitrust lawsuit joined by 38 attorneys general, which alleged that it maintained monopoly power over the internet-search market through anticompetitive contracts and conduct.

Google has also disputed the contentions in that suit, as well as a previous lawsuit filed by the Justice Department on Oct. 20 over alleged monopoly practices.