1987 Madrid City Council election

The 1987 Madrid City Council election, also the 1987 Madrid municipal election, was held on Wednesday, 10 June 1987, to elect the 3rd City Council of the municipality of Madrid. All 55 seats in the City Council were up for election. The election was held simultaneously with regional elections in thirteen autonomous communities and local elections all throughout Spain, as well as the 1987 European Parliament election.

The Spanish Socialist Workers' Party (PSOE) won the election, but lost its absolute majority and lost 137,000 votes compared to 1983. The People's Alliance (AP), which stood separately after the breakup of the People's Coalition in 1986, failed to meet the level of support reached by the coalition in 1983 and also lost votes and seats. Benefitting from both parties' losses was the Democratic and Social Centre (CDS), which, with its 8 seats and 15% of the votes, entered the City Council for its first and only time and went on to hold the balance of power. United Left (IU), an electoral coalition comprising the Communist Party of Spain and other left-wing parties, continued on its long-term decline and lost 1 more seat, barely obtaining 100,000 votes and 6% of the share.

AP and CDS together reached an absolute majority, but failure on reaching an agreement resulted in Socialist Juan Barranco being re-elected as mayor. However, on June 1989, both parties agreed to present a motion of censure on Barranco and elect Agustín Rodríguez Sahagún from the CDS as new mayor, ousting the PSOE from power in the city after a 10-year rule.

Electoral system
The City Council of Madrid (Ayuntamiento de Madrid) was the top-tier administrative and governing body of the municipality of Madrid, composed of the mayor, the government council and the elected plenary assembly. Voting for the local assembly was on the basis of universal suffrage, which comprised all nationals over 18 years of age, registered in the municipality of Madrid and in full enjoyment of their political rights, as well as resident non-nationals whose country of origin allowed Spanish nationals to vote in their own elections by virtue of a treaty.

Local councillors were elected using the D'Hondt method and a closed list proportional representation, with an electoral threshold of five percent of valid votes—which included blank ballots—being applied in each local council. Councillors were allocated to municipal councils based on the following scale:

The mayor was indirectly elected by the plenary assembly. A legal clause required that mayoral candidates earned the vote of an absolute majority of councillors, or else the candidate of the most-voted party in the assembly was to be automatically appointed to the post. In the event of a tie, the appointee would be determined by lot.

The electoral law allowed for parties and federations registered in the interior ministry, coalitions and groupings of electors to present lists of candidates. Parties and federations intending to form a coalition ahead of an election were required to inform the relevant Electoral Commission within ten days of the election call, whereas groupings of electors needed to secure the signature of a determined amount of the electors registered in the municipality for which they were seeking election, disallowing electors from signing for more than one list of candidates. For the case of Madrid, as its population was over 1,000,001, at least 8,000 signatures were required.

Opinion polls
The table below lists voting intention estimates in reverse chronological order, showing the most recent first and using the dates when the survey fieldwork was done, as opposed to the date of publication. Where the fieldwork dates are unknown, the date of publication is given instead. The highest percentage figure in each polling survey is displayed with its background shaded in the leading party's colour. If a tie ensues, this is applied to the figures with the highest percentages. The "Lead" column on the right shows the percentage-point difference between the parties with the highest percentages in a poll. When available, seat projections determined by the polling organisations are displayed below (or in place of) the percentages in a smaller font; 28 seats were required for an absolute majority in the City Council of Madrid.