The announcement late Wednesday followed a global backlash over sexualised images of women and children, including bans and warnings by some governments.
The pushback included an investigation announced on Wednesday by the state of California into the proliferation of non-consensual sexually explicit material produced using Grok that it said was harassing women and girls.
Initially, media queries about the problem drew only the response: "Legacy media lies."
Musk's company, xAI, now says it will geoblock content if it violates laws in a particular place.
"We have implemented technological measures to prevent the Grok account from allowing the editing of images of real people in revealing clothing such as bikinis, underwear and other revealing attire," it said.
The rule applies to all users, including paid subscribers, who have access to more features.
The company has also limited image creation or editing to paid subscribers only "to ensure that individuals who attempt to abuse the Grok account to violate the law or our policies can be held accountable".
Grok's "spicy mode" had allowed users to create explicit content, leading to a backlash from governments worldwide.
Malaysia and Indonesia took legal action and blocked access to Grok.
The UK and European Union were investigating potential violations of online safety laws.
France and India have also issued warnings, demanding stricter controls, and Brazil has called for an investigation into Grok's misuse.
The British government, which has been one of Grok's most vociferous critics in recent days, has welcomed the change, while the country's regulator, Ofcom, said it would carry on with its investigation.
"I shall not rest until all social media platforms meet their legal duties and provide a service that is safe and age-appropriate to all users," Technology Secretary Liz Kendall said.
California Attorney-General Rob Bonta urged xAI to ensure there is no further harassment of women and girls from Grok's editing functions.
"We have zero tolerance for the AI-based creation and dissemination of non-consensual intimate images or of child sexual abuse material," he said.
California has passed laws to shield minors from AI-generated sexual imagery of children and require AI chatbot platforms to remind users they aren't interacting with a human.
But Democratic Governor Gavin Newsom also vetoed a law in 2025 that would have restricted children's access to AI chatbots.