Air Europa will be the first of what is expected to be a number of carriers to have their tickets available for sale on the Ryanair website.
The Spanish airline will be part of a "feed and connecting" programme that allows Ryanair users to book tickets on long-haul flights.
The pair will not code share flight numbers but later this year the website will allow customers to connect onto Air Europa flights through the same booking.
Air Europa flies from the Spanish capital to destinations in Argentina, Brazil, Cuba, Mexico and the US. Ryanair has over 50 routes into Madrid.
The long-haul connection initiative has been talked about for quite some time, with Norwegian one of the airlines touted as a likely partner.
Ryanair CEO Michael O'Leary says:
"We continue to speak to a number of other long haul airlines about potential connecting flight partnerships and we look forward to offering our 130m customers an even greater choice and range of long-haul services in 2018."
Ryanair has launched a number of initiatives in recent years to transform the company as part of its Always Getting Better project, primarily around digital services and turning its brand into what it claims will be an Amazon-style marketplace for travel.
One of the early moves came in 2014 when it returned to the Global Distribution Systems (initially with Travelport) after an absence of a decade.