(Adds background, details)

ANKARA, Jan 20 (Reuters) - Turkish President Tayyip Erdogan said on Monday that Somalia had invited Turkey to explore for oil in its seas, after Ankara signed a maritime agreement with Libya last year, broadcaster NTV reported.

Turkey has been a major source of aid to Somalia following a famine in 2011 as Ankara seeks to increase its influence in the Horn of Africa to counter Gulf rivals like Saudi Arabia and the United Arab Emirates.

Turkish engineers are helping build roads in Somalia, and Turkish officers have trained Somali soldiers as part of efforts to build up the country's army.

Speaking to reporters on his flight back from a Libya summit in Berlin, Erdogan said Turkey would take steps in line with the Somali invitation, but did not elaborate further.

"There is an offer from Somalia. They are saying: 'There is oil in our seas. You are carrying out these operations with Libya, but you can also do them here.' This is very important for us," Erdogan was cited as saying by NTV. "Therefore, there will be steps that we will take in our operations there."

In late December, a group of Turkish engineers was among those hit in a blast at a checkpoint in Mogadishu that killed at least 90 people. At the weekend, a car bombing wounded some 15 people, including Turkish contractors, in Afgoye in an attack claimed by Somali insurgents.

In November, Turkey signed a maritime delimitation deal with Libya's internationally recognised Government of National Accord (GNA), in a move that infuriated Greece and Cyprus. Athens has been at odds with Ankara over offshore resources off the coast of the divided island of Cyprus. (Reporting by Tuvan Gumrukcu; Editing by Dominic Evans)

Our Standards: The Thomson Reuters Trust Principles.