WASHINGTON — Months before he was killed in Istanbul, Jamal Khashoggi was invited up to the office of Crown Prince Mohammed bin Salman's brother, Prince Khalid bin Salman, the Saudi ambassador to the United States, for a friendly meeting at the Saudi Embassy in Washington, three people with knowledge of the meeting told NBC News.

Khashoggi, a prominent critic of the Saudi government, was visiting on a routine consular matter, but he was quickly recognized by embassy officials, who immediately called up to Prince Khalid's top-floor office. Soon, word was sent summoning Khashoggi upstairs, and the two spent roughly half an hour together.

The meeting at the tree-lined embassy, just across from the famed Watergate, took place in early 2018 or late 2017. It was described to NBC News by two of Khashoggi's friends, whom he told about the meeting, and by a third person who was told of the meeting by embassy officials. The Saudi Embassy confirmed that the meeting took place.

What exactly Khashoggi and Prince Khalid discussed is not clear. But the meeting came amid a monthslong campaign by the Saudi royal court to lure Khashoggi back to the kingdom — at first peacefully, through cordial encouragement, and then through more forceful means, which culminated in his killing early this month in the Saudi Consulate in Istanbul.

A friend of Khashoggi's recalled asking him whether Khalid, 30, who is Crown Prince Mohammed's younger brother, had been aggressive or threatening.

"He said, 'No, we just had a nice chat, and he was quite nice,'" the friend recalled Khashoggi saying.

Both Prince Khalid and Saud bin Abdullah Al Qahtani, a senior royal court adviser who was fired Friday for his role in Khashoggi's killing, had been contacting Khashoggi for at least a year to try to persuade him to return, all three people said. They said the Saudi officials had told Khashoggi, who had been living abroad in self-imposed exile, that despite his outspoken criticism of Saudi leadership, he would be welcomed back warmly to Saudi Arabia and could essentially write his own ticket upon his return.

Over the summer, Al Qahtani even offered Khashoggi a high-level job in the royal court or in a Saudi think tank, the two friends of Khashoggi's said.

"He started off, 'Oh, Jamal, come home, you miss being here, blah blah blah, all is forgiven and we'll give you a nice job,'" said a friend to whom Khashoggi described the offer from Al Qahtani.

The campaign to court Khashoggi was in line with a standing directive that has been in effect for years from Saudi intelligence, four people with knowledge of the directive said: When possible, Saudi officials should negotiate with dissidents and others who have left the kingdom to bring them home and back into the Saudi fold.

But Khashoggi was unconvinced by the outstretched hand, said the two friends and another person who was in communication with Khashoggi before his death. He feared that it was a ruse and that upon returning to the kingdom he would be imprisoned or worse, they added.

Saudi Arabia's government, while denying any premeditated order to kill Khashoggi, has admitted trying to bring him back to the kingdom. In its first acknowledgement of Khashoggi's death on Friday, the Saudis said the 15-man team was dispatched by Saudi intelligence to Istanbul because "there were indications of the possibility of his return to the country."

When the negotiations went sour, a fight broke out and Khashoggi was killed, Saudi Arabia says. But Turkey's government insists that the team went to Istanbul to murder Khashoggi, and it claims to have audiotapes proving that he was killed and dismembered within minutes of having entered the consulate, where he was seeking a document he needed for his coming wedding.

Prince Khalid, known informally by the nickname KBS, returned to Riyadh, the Saudi capital, amid the investigation into Khashoggi's disappearance and has not returned to the United States, fueling widespread speculation that he may not return as ambassador. Members of Congress and other U.S. officials have expressed frustration at having been being told a version of events by the ambassador that turned out to be false: that Khashoggi had left the consulate alive.

The State Department has said it expects answers from Prince Khalid when he returns and that the United States is unaware of any change in his status as ambassador. The Saudi Embassy and the Foreign Ministry in Riyadh have not announced any change in leadership, even as speculation mounts about potential replacements.

In a long text message that Prince Khalid sent to contacts in Washington four days after Khashoggi disappeared and later distributed to the media by the Saudi Embassy, Prince Khalid said the missing Washington Post columnist "has many friends in the Kingdom, including myself." He said he and Khashoggi had "maintained regular contact when he was in Washington."

"Jamal is a Saudi citizen whose safety and security is a top priority for the Kingdom, just as is the case with any other citizen," Prince Khalid wrote on Oct. 8. "We will not spare any effort to locate him."