Donald Trump has delivered a mixed message on his attitude to gay rights over the years. (File)

Donald Trump says it's "great" that a gay Democratic challenger, Pete Buttigieg, is in the 2020 presidential race.

A previously little known mayor of South Bend, Indiana, Buttigieg has raced to prominence as one of the top contenders in a crowded Democratic field -- and as the first major presidential candidate to be openly homosexual.

"I think it's absolutely fine, I do," Trump told Fox News in an excerpt released Thursday of an interview airing Sunday.

"I think it's great. I think that's something that perhaps some people will have a problem with. I have no problem with it whatsoever. I think it's good," Trump said.

Buttigieg is married and if he won the White House -- still a very big if -- his husband Chasten would likely be known as the "first gentleman."

Whether Buttigieg gets his party's nomination or not, his bid has already made him and Chasten the country's most prominent gay couple.

Trump, whose right-wing base is broadly hostile to gay marriage, has delivered a mixed message on his attitude to gay rights over the years.