WASHINGTON (Reuters) - A close ally of Donald Trump said talks about the cost of building a wall with Mexico was not supposed to be part of the discussion during Republican presidential candidate's recent meeting with Mexican President Enrique Pena Nieto.

After the two met in Mexico last Wednesday, Trump told reporters they did not discuss his demand that Mexico pay the cost for construction of a wall on the border between the two countries.

Hours later, however, Pena Nieto said on Twitter he did raise the issue of the cost of the wall.

"At the beginning of the conversation with Donald Trump, I made it clear that Mexico will not pay for the wall," Pena Nieto said in a tweet.

Speaking on CNN's State of the Union, former New York Mayor Rudy Giuliani, who accompanied Trump on the visit and was in the room during the meeting, said ground rules had been set prior to the discussion and advisers to the Republican presidential candidate and Pena Nieto's team had agreed the cost of the wall would not be part of the conversation.

"We were not going to discuss paying for the wall because that's not something we're going to agree about," he said.

Giuliani acknowledged that the subject nonetheless was brought up by Pena Nieto.

"Maybe the president's staff didn't brief him on it, maybe he forgot about it, so he brought it up," Giuliani said. "It wasn't right at the very beginning, it was sort of in the middle and I just briefly said 'that's not on the table.'"

Trump has characterized Mexican immigrants to the U.S. as rapists and drug dealers. In a newspaper article a day after the meeting, Pena Nieto said he made clear to Trump that "in Mexico, we feel offended and hurt by his pronouncements about Mexicans."

Instead of focusing on what they didn't agree on, Giuliani said the "very productive conversation" focused on issues the two countries had in common, such as trade-related issues with China.

"All the same complaints you hear from Donald Trump, President Pena Nieto would say exactly the same thing," he said. "The same kind of dumping, the same kind of violation of a lot of the trade rules and regulations."

(Reporting by Toni Clarke; Editing by Caren Bohan and Alan Crosby)